Allow this() { } for structs

Paul Backus snarwin at
Sat Nov 7 15:25:16 UTC 2020

On Saturday, 7 November 2020 at 15:18:27 UTC, IGotD- wrote:
> 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.

Worth noting that this is already how things work for nested 
types. T.init is a compile-time constant and has its context 
pointer set to null, while T() initializes the context pointer at 

More information about the Digitalmars-d mailing list