On Wednesday, 18 January 2017 at 15:29:43 UTC, Mark wrote:
On Tuesday, 17 January 2017 at 15:59:26 UTC, Andrei
Alexandrescu wrote:
On 1/17/17 12:08 PM, Mark wrote:
On Tuesday, 17 January 2017 at 09:17:56 UTC, Andrei
Alexandrescu wrote:
[...]
Given that D supports class invariants, is there a real need
for
predicated setters?
The invariant is evaluated after the setter has taken place,
i.e. after the object has been corrupted. The setter guard
prevents corruption from happening. -- Andrei
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).
You can call invariant directly with `assert(this);` IIRC.