Struct with default ctor (Was: [dmd-beta] dmd 2.064 beta take 2)
Maxim Fomin
maxim at maxim-fomin.ru
Sun May 19 21:18:29 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
>
I think this should be fixed otherwise @disable this() is
compromised. What is rationale behind allowing .init?
More information about the Digitalmars-d
mailing list