Communicating between in and out contracts
Rainer Deyke
rainerd at eldwood.com
Sat Oct 17 19:50:01 PDT 2009
Andrei Alexandrescu wrote:
> If x is a complex expression and part of a complex control flow, it
> becomes highly difficult what it means "at the beginning of the
> function". It also becomes difficult to find a way to distinguish good
> cases from bad cases without being overly conservative.
It looks like a more or less straightforward AST transformation to me.
in {
} body {
F();
} out {
G(old(x));
}
=>
{
auto old_x = x;
try {
F();
} finally {
G(old_x);
}
}
Repeat for each instance of 'old', in order of appearance. OK, it's not
entirely trivial, but it's not prohibitively difficult either.
--
Rainer Deyke - rainerd at eldwood.com
More information about the Digitalmars-d
mailing list