Discussion Thread: DIP 1035-- at system Variables--Community Review Round 2
Walter Bright
newshound2 at digitalmars.com
Fri Feb 26 09:57:03 UTC 2021
> Example: Short String
This example boils down to an invariant not being maintained if the struct is
void-initialized. A couple simple solutions come to mind:
1. disallow void initialization in @safe code if the struct has a constructor
2. disallow void initialization if the struct has an invariant
I suggest that the ShortString struct is not properly written, because it has a
hidden invariant that was not made clear with an explicit:
invariant { assert(length <= data.length); }
More information about the Digitalmars-d
mailing list