Struct no-arg constructor?

Simen Kjaeraas simen.kjaras at gmail.com
Wed Jul 25 03:43:37 PDT 2012


On Wed, 25 Jul 2012 12:30:56 +0200, monarch_dodra <monarchdodra at gmail.com>  
wrote:

> I read TDPL back to back like 5 times before posting this, but it never  
> mentions opCall. I just checked the index right now, it is not in there.  
> Is this new?

Hardly. Once upon a time, in the bad old days, structs didn't have
constructors. In their stead, we used static opCall.

Then, many moons later, we got @disable this();, and now I sorta think
a struct default constructor should simply be syntactic sugar for

@disable this();

static typeof(this) opCall( ) {
     // body
}


I'm not completely sold, though. It feels a bit too much like magic.

--
Simen


More information about the Digitalmars-d mailing list