compiler.let_


compiler.let_(bindings, expr)
compiler.letfn_(bindings, expr)
compiler.letrec_(bindings, expr)
compiler.named_let(n, bindings, expr)
      

Return the intermediate language code required to evaluate body in the context established by bindings. Bindings must be a list of two-element lists that map symbolic identifiers to values.

Examples:


eval(compiler.letfn_([['a, 1], ['b, 2]], compiler.call('list, ['a, 'b])))
// [1, 2]

eval(compiler.let_([['a, 1], ['b, 'a]], compiler.call('list, ['a, 'b])))
// [1, 1]

/* generate and evaluate the code below:
letfn iter (i = 0)
  when (i < 5)
  { showln(i)
    iter(inc(i)) }
*/            
eval(compiler.named_let('iter, [['i, 0]],
      compiler.when_(compiler.call('`<`, ['i, 5]),
        compiler.block([compiler.call('showln, ['i]),
                        compiler.call('iter, [compiler.call('inc, ['i])])]))))

//> 0
    1
    2               
    3
    4          
      

Also see:

compiler


Core Module Index | Contents