opDispatch and compile time parameters
Adam D. Ruppe via Digitalmars-d
digitalmars-d at puremagic.com
Mon Oct 19 11:26:44 PDT 2015
On Monday, 19 October 2015 at 18:16:15 UTC, Andrei Alexandrescu
wrote:
> Tangentially related: since when we allow field initialization
> with new? I was surprised to see that this works:
Since CTFE started supporting it... this might actually be an
unintentional feature.
Since the initializer is in a static context, the right hand side
gets CTFE'd, which means that actually points to an array in the
data segment... the *same* array in the data segment for all
initializations (the pointer is just blitted over with the rest
of init), which might be a bit surprising.
I've seen a lot of people do this with classes not realizing it
makes a static instance!
More information about the Digitalmars-d
mailing list