On Sat, 11 Aug 2012 13:24:12 +0200, Marco Leise <marco.le...@gmx.de> wrote:

Am Fri, 10 Aug 2012 15:56:53 +0200
schrieb Timon Gehr <timon.g...@gmx.ch>:

int eval(scope Expr* e){
     final switch(e.tag) with(Expr.Tag){
         case val:   return e.i;
         case plus:  return eval(e.a) + eval(e.b);
         case minus: return eval(e.a) - eval(e.b);
     }
}

Can you quickly explain the use of scope here? Does that mean "I wont keep a reference to e"? What are the implications? Does scope change the method signature? Does the compiler enforce something? Will generated code differ? Does it prevent bugs or is it documentation for the user of the function?
Thanks in advance for some insight!


If I'm not mistaken, scope will enforce that the reference never escapes the function. So you cannot pass it to other functions that might keep it's reference or store it in any way.

Reply via email to