D const design rationale

Jason House jason.james.house at gmail.com
Mon Jun 25 03:30:28 PDT 2007


Jascha Wetzel wrote:
> Reiner Pope wrote:
>> As storage classes, const and invariant both mean "compile-time 
>> constant" -- their initializers must be evaluatable at compile time, 
>> and their data need not be stored in memory.
> 
> the docs aren't very clear about that, but it's not fully correct when 
> you think about function parameters. the "initializers" of function 
> parameters are the arguments to the call, which need not be evaluatable 
> at compile time.


That part of the documentation actually bugged me.

One of the really nice features of pre-2.0 D was the option to delay 
initialization of const variables to the constructor... either a class 
constructor or static this(){}.



More information about the Digitalmars-d mailing list