Logical const

Walter Bright newshound2 at digitalmars.com
Wed Dec 1 11:11:39 PST 2010


Jonathan M Davis wrote:
> Also, a classic example for the use of const which immutable doesn't help you 
> with it all is returning member variables by reference or which are reference 
> types when you don't want the caller to be able to modify them. Without const, 
> you couldn't do that. const is huge. I'd _hate_ to see const go. The fact that D 
> has const is one of the best things that it has going for it IMHO. I _hate_ the 
> fact that languages like Java don't. It drives me nuts. Sure, you _can_ write 
> programs without const - people do it all the time - but you have far fewer 
> guarantees about your code, and it's much harder to determine which a function 
> may or may not alter the value of a variable when you call it.

As far as I know, D is the only language with a workable, enforcable, const 
system. That means we're the pioneers in getting this done right. It's up to us 
to show that it is an advantage.


More information about the Digitalmars-d mailing list