diff options
author | Anthony Ramine <[email protected]> | 2012-11-10 17:06:01 +0100 |
---|---|---|
committer | Anthony Ramine <[email protected]> | 2013-12-12 10:46:08 +0100 |
commit | acbca8379bdde12612e27f3313a5c73f4db25381 (patch) | |
tree | 536f5f2d71f4ef1339b03472048e1b932d7064c5 /bootstrap/lib/stdlib/ebin/epp.beam | |
parent | 6c5c39827cc06a9e9b3e3fa4fa856f4610eb40b6 (diff) | |
download | otp-acbca8379bdde12612e27f3313a5c73f4db25381.tar.gz otp-acbca8379bdde12612e27f3313a5c73f4db25381.tar.bz2 otp-acbca8379bdde12612e27f3313a5c73f4db25381.zip |
EEP 37: Funs with names
This adds optional names to fun expressions. A named fun expression
is parsed as a tuple `{named_fun,Loc,Name,Clauses}` in erl_parse.
If a fun expression has a name, it must be present and be the same in
every of its clauses. The function name shadows the environment of the
expression shadowing the environment and it is shadowed by the
environment of the clauses' arguments. An unused function name triggers
a warning unless it is prefixed by _, just as every variable.
Variable _ is allowed as a function name.
It is not an error to put a named function in a record field default
value.
When transforming to Core Erlang, the named fun Fun is changed into
the following expression:
letrec 'Fun'/Arity =
fun (Args) ->
let <Fun> = 'Fun'/Arity
in Case
in 'Fun'/Arity
where Args is the list of arguments of 'Fun'/Arity and Case the
Core Erlang expression corresponding to the clauses of Fun.
This transformation allows us to entirely skip any k_var to k_local
transformation in the fun's clauses bodies.
Diffstat (limited to 'bootstrap/lib/stdlib/ebin/epp.beam')
0 files changed, 0 insertions, 0 deletions