November 07, 2020
On Saturday, 7 November 2020 at 15:00:51 UTC, FeepingCreature wrote:
>
> 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.

November 07, 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 runtime.
1 2
Next ›   Last »