Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)
Bottled Gin
gin at bottled.com
Mon May 20 18:34:15 PDT 2013
On Monday, 20 May 2013 at 00:55:14 UTC, Kenji Hara wrote:
> Unfortunately this is currently not a bug.
> T.init provides "default initialized" object image, and it
> *does not*
> provide "default constructed" object. The difference is
> important.
>
> That is already documented in lanugage reference.
> http://dlang.org/property#init
>
>> Note: .init produces a default initialized object, not default
> constructed. That means using .init is sometimes incorrect.
>> 1. If T is a nested struct, the context pointer in T.init is
>> null.
>> 2. If T is a struct which has @disable this();, T.init might
>> return a
> logically incorrect object.
>
> Kenji Hara
>
In that case, kindly let me understand why it is not possible to
allow explicit default constructor for structs given that:
1. The constructor gets called at run time.
2. Is not considered for evaluating S.init (compile time).
More information about the Digitalmars-d
mailing list