Getters/setters generator

Mark via Digitalmars-d-announce digitalmars-d-announce at puremagic.com
Thu Jan 19 03:34:52 PST 2017


On Wednesday, 18 January 2017 at 21:57:42 UTC, Andrei 
Alexandrescu wrote:
> On 1/18/17 5:29 PM, Mark wrote:
>> I see. Is there a way to call invariant() of a class/struct 
>> directly?
>> That would obviate the need for a particular predicate (copy 
>> the class
>> state, run the setter, check if invariants are satisfied and 
>> restore
>> previous state if they aren't).
>
> It seems painfully obvious the right way is a guarded 
> assignment and anything else would be a more or less painful 
> workaround. -- Andrei

I agree. I'm just a bit unsettled by the slight code duplication 
that would ensue.


More information about the Digitalmars-d-announce mailing list