T.init, struct destructors and invariants - should they be called?

FeepingCreature feepingcreature at gmail.de
Sun Jul 8 03:06:44 UTC 2018


On Friday, 6 July 2018 at 23:37:30 UTC, Simen Kjærås wrote:
> As for alignment, GC, and possibly other things, the code was 
> not intended as a complete implementation of Nullable, only to 
> show that an actual member of type T is not necessary. These 
> issues are fixable, if perhaps nontrivial in some cases.
>
> --
>   Simen

Yeah, sorry - that was a snap answer; union is indeed not a 
solution, particularly since it doesn't even work for types with 
elaborate destructors.

That said, I agree that this can be implemented, however imo the 
fact that we have to retrace the work of the compiler in laying 
out the data is a warning sign - imo, it happens because what we 
actually want is for the compiler to *work a different way*, 
which is why we find ourselves painstakingly recreating its 
interna in userland, except with different destructor semantics. 
This points at a flaw in the language, imo - if we so urgently 
need a way to express different semantics, we shouldn't have to 
painstakingly hide the type behind the compiler's back; the 
compiler should have our back in this instead of fighting us.


More information about the Digitalmars-d mailing list