Questions tagged [readonly-variable]

14 questions
5
votes
1 answer

Does Having Hundreds of Readonly Static Variables Cause Performance Issues?

I am working on a new Asp.Net MVC project and this time to have better control over the static contents of the application, I am planning to store all content as reusable properties in readonly static variables. These values are not going to change…
5
votes
3 answers

Kotlin - Read Only properties in interfaces

I have this utility interface to be implemented by RecyclerView's ViewHolder that fires UI events. interface ObservableMvpViewHolder { val listeners: List fun registerListener(listener:V) fun unregisterListener (listener:…
alexpfx
  • 6,412
  • 12
  • 52
  • 88
3
votes
2 answers

What is the difference between .rodata and .rdata

I've seen both .rodata and .rdata being used as segments. Which one should I use and what are the differences between them?
Ark
  • 73
  • 2
  • 8
3
votes
1 answer

How do I change a Perl Readonly scalar in a module for a unit test?

The only help I've found on the internet so far is this blog. Which I thought was going to get me there, but I don't think it's actually changing the values in my module. I made a sample to show what I mean. package Module; use 5.012; use…
Eric Fossum
  • 2,395
  • 4
  • 26
  • 50
2
votes
1 answer

Are C optimizing compilers (GCC) able to detect unchanging values for read-only access without the use of 'const'?

My searches have turned up blank on this question... There are plenty of discussions of how const may be helpful in compiler optimization by signaling read-only access of a variable, but I can't find an answer to the question as posed in the title.…
Theo d'Or
  • 783
  • 1
  • 4
  • 17
1
vote
1 answer

How to make global variables "immutable" in Lua/LuaJ?

Description I'm doing a LuaJ program, and here's a lib script like this: function foo() print("foo"); end I want the foo function can be invoked in other scripts directly (no require), but performs immutable in different scripts. ( Even a…
1
vote
2 answers

Changing value of readonly array

I have this jagged array in C#: private static readonly float[][] Numbers = { new float[]{ 0.3f, 0.4f, 0.5}}; How can I override the value? public static void SetNewNumbers(float[][] num){ Numbers = num;} This is not working because of…
DD995
  • 11
  • 1
1
vote
1 answer

Why does Powershell not throw an error when we do $NULL="FOO"?

I was trying to understand how the constants $TRUE, $FALSE and $NULL work in Powershell, and how I should test for them or compare them with variables, respectively. Being a Powershell newbie, I did some basic tests. While $TRUE and $FALSE behaved…
Binarus
  • 4,005
  • 3
  • 25
  • 41
0
votes
0 answers

BASH bug or feature?: Shadowing a readonly global variable with a writable local variable

(Possibly this is the same question as Function local read-only vs. global read-only variable with the same name) In a script I wrote I'm using readonly key="$1" (for the program parameter) at the global level, and a function uses local key="$1"…
U. Windl
  • 3,480
  • 26
  • 54
0
votes
0 answers

Cannot convert value of type '() -> [Any]' to specified type '[(TextFormatType, UIButton)]'

I'm getting error when i try to extract toolbarStyles from here and create a read-only computed property. private func toolbarButtons(toolbar: Toolbar) { guard let selection = getSelection() else { return } var toolbarStyles:…
userNew
  • 11
  • 3
0
votes
2 answers

Is there a way to mark a function as only called/callable from a static constructor?

I have quite a sizeable static constructor for one of my classes, and was wanting to refactor it to encapsulate various bits of the initialization within static functions. One of the things this static constructor does a lot of is initialize the…
0
votes
1 answer

Pass a readonly field from C# as a const double&

In our project we have a readonly struct for a 3-dimensional vector (x,y,z) defined in C# like this: public readonly struct Vec3 { public readonly double X, Y, Z; ... } and we want to, in C++/CLI code, call what is essentially the…
Todd Burch
  • 200
  • 8
0
votes
2 answers

How can we check whether a variable is readonly or not in linux

How can we check under if whether a variable is readonly or not? Please Explain with Examples
-1
votes
3 answers

What is the difference between `state` and `const`?

It seems similar to write: use Const::Fast; const $xx, 77; sub test { do_something_with( $xx ); } or sub test { state $xx = 77; do_something_with( $xx ); } What is the better way to accomplish this: via const or via state? sub…
Eugen Konkov
  • 22,193
  • 17
  • 108
  • 158