EExpr
From Erights
(Difference between revisions)
m |
|||
(One intermediate revision not shown) | |||
Line 9: | Line 9: | ||
The CompiledE is also useful if you want to debug the optimiser: | The CompiledE is also useful if you want to debug the optimiser: | ||
- | ? def expr := e`def double | + | ? def expr := e`def double (x) { return 2*x }` |
# value: e`def double { | # value: e`def double { | ||
# | # |
Latest revision as of 14:44, 9 June 2010
A parsed Kernel-E expression.
Protocol
compile/1
- Signature: compile(env :Scope) :CompiledE
Compile the expression to an internal form (currently transformed E, but could be Java bytecode). The result is a Thunk which can be invoked to evaluate the code in the given environment.
The CompiledE is also useful if you want to debug the optimiser:
? def expr := e`def double (x) { return 2*x }` # value: e`def double { # # method run(x) { # escape __return { # __return.run(2.multiply(x)) # null # } # } # }` ? expr.compile(safeScope) # value: compiled-e`def double { # # method run(x) { # 2.multiply(x) # } # }`
eval/1
- Signature: eval(env :Scope) :any
Convenience method to compile and evaluate the expression in one go.