Would you like to try const-by-default or not?

torhu fake at address.dude
Mon Jun 11 08:36:45 PDT 2007


Rioshin an'Harthen wrote:
> 
> I'd definitely go for option 2 - having had to code const correct C++, I 
> know
> what kind of a pain it is. Much simpler to have every parameter be const by
> default and add mutable/variant etc. in front of those the compiler 
> complains
> about. Voila! Automatically const correct code. 
> 

'var' is shorter than 'mutable', so that might be a good option for a 
keyword in this case.  Depends if D is going to adopt the C++ 'mutable' 
concept, in that case reusing mutable might be a better option.

Pascal uses 'var' for out parameters, but it works like inout or ref in 
D, not quite like the intended meaning of mutable in D.  But still...



More information about the Digitalmars-d mailing list