Runtime constant definitions
Jarrett Billingsley
jarrett.billingsley at gmail.com
Fri Sep 12 05:49:30 PDT 2008
On Fri, Sep 12, 2008 at 4:20 AM, Lars Kyllingstad
<public at kyllingen.nospamnet> wrote:
> Frank Benoit wrote:
>>
>> I think 'const' should work.
>
> It works! Thanks! :)
>
> But isn't this the opposite of the intended behaviour? I thought consts were
> evaluated at compile time, and finals and static this() blocks at run time.
> At least that's how I've interpreted the D1 specs.
>
> -Lars
>
http://www.digitalmars.com/d/1.0/attribute.html#const
"A const declaration without an initializer must be initialized in a
constructor (for class fields) or in a static constructor (for static
class members, or module variable declarations). "
To be honest I'm not sure if the "un-reassignable" property of "final"
is documented anywhere. There is a mention in the 1.011 changelog
that "final for variables now works" but I don't know what "works"
means.
More information about the Digitalmars-d-learn
mailing list