[erlang-patches] EEP37: Funs with names

Anthony Ramine n.oxyde@REDACTED
Wed Nov 21 15:36:10 CET 2012


Hi,

I had forgotten to update the abstract format documentation, named_fun is
now mentioned in absform.xml in the doc commit.

Please refetch,

-- 
Anthony Ramine

Le 15 nov. 2012 à 15:22, Henrik Nord a écrit :

> I will add this patch to 'master-pu'.
> 
> Thank you for your contribution!
> 
> 
> On 2012-11-14 17:42, Anthony Ramine wrote:
>> This patch implements EEP37: 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.
>> 
>> 	https://github.com/nox/otp/compare/erlang:master...eep37
>> 	https://github.com/nox/otp/compare/erlang:master...eep37.patch
>> 
>> 	git fetch https://github.com/nox/otp eep37
>> 
>> Regards,
>> 
> 
> -- 
> /Henrik Nord Erlang/OTP
> 




More information about the erlang-patches mailing list