The Erlang meta interpreter.
This module provides an interpreter for Erlang expressions. The expressions are in the abstract syntax as returned by erl_parse, the Erlang parser, or io.
func_spec() =
{Module :: module(), Function :: atom()} | function()
Types
Adds binding Name=Value to BindingStruct. Returns an updated binding structure.
binding(Name, BindingStruct) -> {value,
value()} | unbound
Types
Returns the binding of Name in BindingStruct.
Returns the list of bindings contained in the binding structure.
Types
Removes the binding of Name in BindingStruct. Returns an updated binding structure.
expr(Expression, Bindings) -> {value, Value, NewBindings}
expr(Expression, Bindings, LocalFunctionHandler) ->
{value, Value, NewBindings}
expr(Expression,
Bindings,
LocalFunctionHandler,
NonLocalFunctionHandler) ->
{value, Value, NewBindings}
expr(Expression,
Bindings,
LocalFunctionHandler,
NonLocalFunctionHandler,
ReturnFormat) ->
{value, Value, NewBindings} | Value
Types
Evaluates Expression with the set of bindings Bindings. Expression is an expression in abstract syntax. For an explanation of when and how to use arguments LocalFunctionHandler and NonLocalFunctionHandler, see sections Local Function Handler and Non-Local Function Handler in this module.
Returns {value, Value, NewBindings} by default. If ReturnFormat is value, only Value is returned.
expr_list(ExpressionList, Bindings) -> {ValueList, NewBindings}
expr_list(ExpressionList, Bindings, LocalFunctionHandler) ->
{ValueList, NewBindings}
expr_list(ExpressionList,
Bindings,
LocalFunctionHandler,
NonLocalFunctionHandler) ->
{ValueList, NewBindings}
Types
Evaluates a list of expressions in parallel, using the same initial bindings for each expression. Attempts are made to merge the bindings returned from each evaluation. This function is useful in LocalFunctionHandler, see section Local Function Handler in this module.
Returns {ValueList, NewBindings}.
exprs(Expressions, Bindings) -> {value, Value, NewBindings}
exprs(Expressions, Bindings, LocalFunctionHandler) ->
{value, Value, NewBindings}
exprs(Expressions,
Bindings,
LocalFunctionHandler,
NonLocalFunctionHandler) ->
{value, Value, NewBindings}
Types
Evaluates Expressions with the set of bindings Bindings, where Expressions is a sequence of expressions (in abstract syntax) of a type that can be returned by io:parse_erl_exprs/2. For an explanation of when and how to use arguments LocalFunctionHandler and NonLocalFunctionHandler, see sections Local Function Handler and Non-Local Function Handler in this module.
Returns {value, Value, NewBindings}
Returns an empty binding structure.
During evaluation of a function, no calls can be made to local functions. An undefined function error would be generated. However, the optional argument LocalFunctionHandler can be used to define a function that is called when there is a call to a local function. The argument can have the following formats:
The non-local function handler argument is probably not used as frequently as the local function handler argument. A possible use is to call exit/1 on calls to functions that for some reason are not allowed to be called.
Undocumented functions in this module are not to be used.