Rainer Deyke wrote:
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.

It is if x is an _arbitrarily complex_ expression, and if that expression is part of a _complex control flow_. The language definition would have to decide exactly where complex is too complex in the expression or the control flow. That complicates the language. Also, by necessity the feature will be limited and will not give people enough freedom. It's lose-lose.

Andrei

Reply via email to