Allow this() { } for structs

IGotD- nise at
Sat Nov 7 15:18:27 UTC 2020

On Saturday, 7 November 2020 at 15:00:51 UTC, FeepingCreature 
> It's not like it doesn't work because the compiler devs 
> couldn't figure out how to do it, it's that it clashes with the 
> notion that all data types should have a valid default value. 
> (As I understand it.) My point with the Nullable thing is that 
> this notion is dead regardless.

I don't understand how this clashes with S.init. You can have a 
S.init and this() which are separate. First always initializing 
to S.init and then run the constructor if it exists. The 
optimizer merges these two steps when it is removing unused 
values. this() of course becomes a runtime initialization unless 
the optimizer figures it out.

More information about the Digitalmars-d mailing list