Out contracts: how to refer to objects' start state
Andrej Mitrovic
andrej.mitrovich at gmail.com
Sat May 25 18:03:08 PDT 2013
On 5/26/13, Andrei Alexandrescu <SeeWebsiteForEmail at erdani.org> wrote:
> class A {
> void fun()
> in { auto oldLen = this.length; }
> out { assert(this.length == oldLen + 1); }
> body { ... }
> }
>
> That was technically difficult to do back then, and fell by the wayside.
> Today it would break too much code to introduce even if feasible.
Perhaps we could support this by allowing qualification of the in block:
out { assert(this.length == in.oldLen + 1); }
"in" is a keyword so it shouldn't break any existing code.
More information about the Digitalmars-d
mailing list