Invariant for default construction

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Mon Nov 17 12:51:37 PST 2014


On 11/17/2014 12:32 PM, Steven Schveighoffer wrote:
> On 11/17/14 3:02 PM, Martin Nowak wrote:
>> Walter is about to fix an old bug [1] so that invariants are now called
>> before destruction and for non-default construction.
>
> This sounds good.
>
>> A remaining question is whether invariants should also be called for
>> default construction [2].
>
> I'd say no. There are better ways to test for valid data in the .init version of
> the object/struct that don't involve a runtime check.

Not only that, the runtime check would occur every time an object is created, 
yet the .init will always be the same. Doing this check would, I fear, cause 
people to disable invariants as not worth the expense.



More information about the Digitalmars-d mailing list