Why are immutable fields with initializers deprecated?

Andrei Alexandrescu via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 29 10:57:28 PDT 2014


On 4/29/14, 10:18 AM, Kenji Hara via Digitalmars-d wrote:
> In future release, non-static const or immutable field will be made an
> instance field.
>
> struct S
> {
>      immutable int x = 1;
> }
> static assert(S.sizeof == int.sizeof);   // will succeed in the future
>
> So current "implicit static" behavior is now deprecated.
>
> Related:
> http://dlang.org/changelog#staticfields
> http://dlang.org/changelog#staticfields2
>
> Kenji Hara

That makes sense - thanks Nick and Kenji! -- Andrei



More information about the Digitalmars-d mailing list