digitalmars.D - Why are immutable fields with initializers deprecated?
- Andrei Alexandrescu (6/6) Apr 29 2014 A recent discussion
- Steven Schveighoffer (6/11) Apr 29 2014 I think possibly it has to do with the fact that they originally did not...
- Nick Treleaven (3/15) Apr 29 2014 http://dlang.org/changelog#staticfields2
- Kenji Hara via Digitalmars-d (14/19) Apr 29 2014 In future release, non-static const or immutable field will be made an
- Andrei Alexandrescu (2/14) Apr 29 2014 That makes sense - thanks Nick and Kenji! -- Andrei
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
Apr 29 2014
On Tue, 29 Apr 2014 13:09:01 -0400, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote: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?I think possibly it has to do with the fact that they originally did not get stored per-instance. I remember a conversation about this (being a bad thing), but have not searched the NG for it. -Steve
Apr 29 2014
On Tuesday, 29 April 2014 at 17:11:50 UTC, Steven Schveighoffer wrote:On Tue, 29 Apr 2014 13:09:01 -0400, Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> wrote:http://dlang.org/changelog#staticfields2A 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?I think possibly it has to do with the fact that they originally did not get stored per-instance. I remember a conversation about this (being a bad thing), but have not searched the NG for it.
Apr 29 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 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
Apr 29 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
Apr 29 2014









"Nick Treleaven" <ntrel-public yahoo.co.uk> 