T.init, struct destructors and invariants - should they be called?
FeepingCreature
feepingcreature at gmail.de
Mon Nov 19 05:17:59 UTC 2018
On Monday, 19 November 2018 at 01:46:34 UTC, Stanislav Blinov
wrote:
> Again, that is not a `union` problem, that's a
> destructor+invariant problem. Types in .init state should be
> destructible, period:
>
> S[] a;
> // can't do this:
> a = new S[10];
> // but still can do this:
> a.length = 10;
Fair enough, I agree with that, it's just been a bit of an uphill
struggle to get people to agree that requiring T.init to pass the
invariants makes struct invariants mostly useless. If you can get
them to agree to a solution that doesn't nerf struct invariants
into the ground, then be my guest - there's a DMD PR that could
be resurrected, https://github.com/dlang/dmd/pull/8462 , or a
better solution found. I just really don't want to have to take
our codebase back to classes for domain values, or comment out
all the invariants we painstakingly added.
More information about the Digitalmars-d
mailing list