The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
2answers
56 views

Mutable cursor in readonly object?

I've been searching for the different uses of the keyword mutable. I've found that it is generally used for caching, lazy computing, mutex, ... But I'm wondering if it is coherent to use it for a ...
11
votes
4answers
698 views

What are the problems of bringing C++-like const into a language?

I am interested in the idea of C++-like const not that particular execution (like casting away const). Take for example C# -- it lacks C++-like const, and the reason for it is the the usual -- people ...
1
vote
1answer
181 views

Are there advantages to declaring stack variables constant in C++

It's not clear to me what benefits there are of declaring your stack variables as constant in C++, I was hoping somebody might explain the benefits and purpose for this technique. For example: void ...
2
votes
1answer
333 views

Which is better to use? (Enum or Constant)

I have my enum like this. enum Size{PAGE_SIZE=20, HEADER_SIZE=30 }; I only use them as constants(No enum variable created) in my program. i.e= int x = PAGE_SIZE + 20; So what is the ...
11
votes
4answers
696 views

When and for what purposes should the const keyword be used in C for variables?

While getting my code reviewed here the issue of using the const keyword came up. I understand that it is used for implementing read-only behaviour on variables. I am confused about what are the ...
1
vote
1answer
112 views

Implementation defined behaviour changing const type in c

The C standard states that if an attempt is made to change a const type,the result is implementation defined.This gives error on my system,but what does it depend on(compiler,os)? What are the ...
2
votes
2answers
345 views

In C# what is lifetime or lifespan of constant variable?

In C# if i declare a constant variable is any memory allocated to it as it acts as a compile time replacement? How long is the variable's life?
3
votes
4answers
802 views

Immutable Method in Java

In Java, there is the final keyword in lieu of the const keyword in C and C++. In the latter languages there are mutable and immutable methods such as stated in the answer by Johannes Schaub - litb ...
2
votes
1answer
61 views

Reading data from file and const

Is it sane to let a read method on a file object to be const? For example size_t read(void* buffer,size_t length) const; The read method does not change the contents of the file, but updates the ...
9
votes
5answers
790 views

Zero as a constant?

I have come across this programming idiom recently: const float Zero = 0.0; which is then used in comparisons: if (x > Zero) {..} Can anyone explain if this is really any more efficient or ...
6
votes
2answers
2k views

Do people use const a lot when programming in Objective C?

Related: “sending 'const NSString *' to parameter of type 'NSString *' discards qualifiers” warning Sometimes, I think it's useful though. I may need to pass an a table and want to make sure that the ...
7
votes
5answers
3k views

Difference between immutable and const

I've often seen the terms immutable and const used interchangeably. However, from my (little) experience, the two differ a lot in the 'contract' they make in code: Immutable makes the contract that ...