Why are immutable fields with initializers deprecated?

Kenji Hara via Digitalmars-d digitalmars-d at puremagic.com
Tue Apr 29 10:18:41 PDT 2014


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


2014-04-30 2:09 GMT+09:00 Andrei Alexandrescu via Digitalmars-d <
digitalmars-d at puremagic.com>:

> A recent discussion https://github.com/D-Programming-Language/dmd/pull/
> 3452 brought up a matter I'd forgotten - struct fields that are immutable
> and have initializer are deprecated.
>
> Why?
>
> Andrei
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140430/8ed2ec43/attachment.html>


More information about the Digitalmars-d mailing list