Using in as a parameter qualifier

Jonathan M Davis jmdavisProg at gmx.com
Fri May 31 15:51:10 PDT 2013


On Friday, May 31, 2013 23:25:02 Jesse Phillips wrote:
> On Friday, 31 May 2013 at 17:50:33 UTC, Shriramana Sharma wrote:
> > Sorry but I still don't get it -- if a default constructor is
> > disallowed for struct-s by the language itself, why should I
> > have to
> > *tell* the compiler to disable it?
> 
> The compiler always provides a default constructor (maybe not
> technically) which is used for .init.
> 
> By requesting the default constructor be disabled, is really
> saying don't let anyone declare the struct without initializing
> it.
> 
> Testing shows that in 2.060 the init property is still usable,
> which I expected as it is most useful in generic code. But I
> don't know if that is sticking around, it is kind of like int a =
> void;

I believe that a disabled init property is still useable in some type 
inference stuff (e.g. typeof(type.init) may still work), but if init has been 
disabled, then you can't use that struct in any situation which requires 
default initialization. It's not like you get = void in the cases where init 
is disabled and you need init. Rather, you just can't use that type in that 
situation.

- Jonathan M Davis


More information about the Digitalmars-d-learn mailing list