Example of Rust code

Marco Leise Marco.Leise at gmx.de
Sat Aug 11 04:24:12 PDT 2012


Am Fri, 10 Aug 2012 15:56:53 +0200
schrieb Timon Gehr <timon.gehr at 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!

-- 
Marco



More information about the Digitalmars-d mailing list