struct init() method
Jonathan M Davis
jmdavisProg at gmx.com
Sun Feb 26 04:22:30 PST 2012
On Sunday, February 26, 2012 13:15:51 Alex Rønne Petersen wrote:
> On 26-02-2012 12:53, Jonathan M Davis wrote:
> > On Sunday, February 26, 2012 12:48:06 Timon Gehr wrote:
> >> On 02/26/2012 12:18 AM, Jonathan M Davis wrote:
> >>> On Saturday, February 25, 2012 17:07:14 Timon Gehr wrote:
> >>>> This is useful:
> >>>>
> >>>> struct S{
> >>>>
> >>>> @disable enum init = 0;
> >>>>
> >>>> }
> >>>
> >>> I thought that the way that you were supposed to do that was
> >>>
> >>> @disable this();
> >>>
> >>> - Jonathan M Davis
> >>
> >> struct S{@disable this();}
> >> void main(){S s = S.init;}
> >
> > Well, that's a problem then. It looks like it's bug - either that or I
> > completely misunderstood what was going on with @disable and structs.
> >
> > - Jonathan M Davis
>
> IMHO .init should yield an error for structs with @disable this().
> Anything else seems illogical.
Well, like I said, it's my understanding that @disable this() is the way that
you're supposed to disable .init - as in that's the whole point of having
added @disable this() to the language (though it can also be used to make
classes unconstructable). So, either my understanding is wrong and/or this is
a bug.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list