O object

Var

extends Object with Serializable

Supertypes

Object, Serializable

Members

def 

apply

[T, U] ( init: Expr[T] ) ( body: Var[T] => Expr[U] ) ( implicit  evidence$1: Type[T] evidence$2: Type[U] qctx: QuoteContext ) : Expr[U]

Create a variable initialized with init and used in body. body receives a Var[T] argument which exposes get and update.

Create a variable initialized with init and used in body. body receives a Var[T] argument which exposes get and update.

Var('{7}) {
  x => '{
    while(0 < ${x.get})
      ${x.update('{${x.get} - 1})}
    ${x.get}
  }
}

will create the equivalent of:

'{
  var x = 7
  while (0 < x)
    x = x - 1
  x
}