Invariants are useless the way they are defined
    Dicebot 
    public at dicebot.lv
       
    Mon Aug 26 10:31:35 PDT 2013
    
    
  
On Monday, 26 August 2013 at 16:49:01 UTC, Peter Alexander wrote:
> On Monday, 26 August 2013 at 14:16:04 UTC, Dicebot wrote:
>> On Monday, 26 August 2013 at 07:20:56 UTC, Davidson Corry 
>> wrote:
>>> ...
>>
>> By the way it makes me think that invariant should run via 
>> CTFE on T.init for all types that have invariant contracts. 
>> The fact that default-initialize value may have a broken 
>> contract greatly diminishes value of the whole system.
>
> Not all invariants can run at compile time.
True, but it will at least make a notable cluster of potential 
issues into compile-time errors. Actually, I'd expect non-CTFE 
invariant to be quite rare - those rarely do any I/O or some 
weird pointer forging.
If invariant is not CTFE-able it should be deferred to runtime to 
the initial point of the aggregate construction.
    
    
More information about the Digitalmars-d
mailing list