From 229d0d8ca88bc344bed89e46541b325c1d267996 Mon Sep 17 00:00:00 2001 From: Hans Bolinder Date: Fri, 6 May 2011 15:58:09 +0200 Subject: r Use Erlang specs and types for documentation --- lib/stdlib/doc/src/erl_eval.xml | 153 ++++++++++++++++++++++++++-------------- 1 file changed, 102 insertions(+), 51 deletions(-) (limited to 'lib/stdlib/doc/src/erl_eval.xml') diff --git a/lib/stdlib/doc/src/erl_eval.xml b/lib/stdlib/doc/src/erl_eval.xml index 62af23c5eb..c95494bf25 100644 --- a/lib/stdlib/doc/src/erl_eval.xml +++ b/lib/stdlib/doc/src/erl_eval.xml @@ -4,7 +4,7 @@
- 19962009 + 19962011 Ericsson AB. All Rights Reserved. @@ -36,63 +36,108 @@

This module provides an interpreter for Erlang expressions. The expressions are in the abstract syntax as returned by - erl_parse, the Erlang parser, or a call to - io:parse_erl_exprs/2.

+ erl_parse, + the Erlang parser, or + io.

+ + + + + + + A binding structure. + + + + + + +

As returned by + erl_parse:parse_exprs/1 or + + io:parse_erl_exprs/2.

+
+ + + + + + + + + + + + + + +

Further described + below.

+
+
+ + + + + + + + +

Further described + below.

+
+
+ + + +
- exprs(Expressions, Bindings) -> {value, Value, NewBindings} - exprs(Expressions, Bindings, LocalFunctionHandler) -> {value, Value, NewBindings} - exprs(Expressions, Bindings, LocalFunctionHandler, NonlocalFunctionHandler) -> {value, Value, NewBindings} + + + Evaluate expressions - - Expressions = as returned by erl_parse or io:parse_erl_exprs/2 - Bindings = as returned by bindings/1 - LocalFunctionHandler = {value, Func} | {eval, Func} | none - NonlocalFunctionHandler = {value, Func} | none - -

Evaluates Expressions with the set of bindings - Bindings, where Expressions is a sequence of +

Evaluates Expressions with the set of bindings + Bindings, where Expressions + is a sequence of expressions (in abstract syntax) of a type which may be - returned by io:parse_erl_exprs/2. See below for an + returned by + io:parse_erl_exprs/2. See below for an explanation of how and when to use the arguments - LocalFunctionHandler and NonlocalFunctionHandler. + LocalFunctionHandler and + NonLocalFunctionHandler.

-

Returns {value, Value, NewBindings}

+

Returns {value, Value, NewBindings} +

- 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 + + + + Evaluate expression - - Expression = as returned by io:parse_erl_form/2, for example - Bindings = as returned by bindings/1 - LocalFunctionHandler = {value, Func} | {eval, Func} | none - NonlocalFunctionHandler = {value, Func} | none - ReturnFormat = value | none - -

Evaluates Expression with the set of bindings - Bindings. Expression is an expression (in - abstract syntax) of a type which may be returned by - io:parse_erl_form/2. See below for an explanation of +

Evaluates Expression with the set of bindings + Bindings. Expression + is an expression in + abstract syntax. See below for an explanation of how and when to use the arguments - LocalFunctionHandler and - NonlocalFunctionHandler. + LocalFunctionHandler and + NonLocalFunctionHandler.

-

Returns {value, Value, NewBindings} by default. But - if the ReturnFormat is value only the Value - is returned.

+

Returns {value, Value, + NewBindings} by default. But if the + ReturnFormat is value only + the Value is returned.

- expr_list(ExpressionList, Bindings) -> {ValueList, NewBindings} - expr_list(ExpressionList, Bindings, LocalFunctionHandler) -> {ValueList, NewBindings} - expr_list(ExpressionList, Bindings, LocalFunctionHandler, NonlocalFunctionHandler) -> {ValueList, NewBindings} + + + Evaluate a list of expressions

Evaluates a list of expressions in parallel, using the same @@ -100,18 +145,19 @@ merge the bindings returned from each evaluation. This function is useful in the LocalFunctionHandler. See below.

-

Returns {ValueList, NewBindings}.

+

Returns {ValueList, NewBindings}. +

- new_bindings() -> BindingStruct + Return a bindings structure

Returns an empty binding structure.

- bindings(BindingStruct) -> Bindings + Return bindings

Returns the list of bindings contained in the binding @@ -119,25 +165,28 @@ - binding(Name, BindingStruct) -> Binding + Return bindings -

Returns the binding of Name in BindingStruct.

+

Returns the binding of Name + in BindingStruct.

- add_binding(Name, Value, Bindings) -> BindingStruct + Add a binding -

Adds the binding Name = Value to Bindings. +

Adds the binding Name = Value + to BindingStruct. Returns an updated binding structure.

- del_binding(Name, Bindings) -> BindingStruct + Delete a binding -

Removes the binding of Name in Bindings. +

Removes the binding of Name + in BindingStruct. Returns an updated binding structure.

@@ -145,7 +194,8 @@
Local Function Handler -

During evaluation of a function, no calls can be made to local +

+ 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 may be used to define a function @@ -191,7 +241,8 @@ Func(Name, Arguments, Bindings)

Non-local Function Handler -

The optional argument NonlocalFunctionHandler may be +

+ The optional argument NonlocalFunctionHandler may be used to define a function which is called in the following cases: a functional object (fun) is called; a built-in function is called; a function is called using the M:F syntax, where M -- cgit v1.2.3