[erlang-questions] Convert atom and arity into fun

Edwin Fine erlang-questions_efine@REDACTED
Tue Sep 9 18:26:42 CEST 2008


Thanks, Bjorn. Is there a good reason it is undocumented? I mean, if I use
it, am I in danger of my code breaking in a future release because of that?
Regards,
Edwin

On Tue, Sep 9, 2008 at 7:58 AM, Bjorn Gustavsson <bgustavsson@REDACTED>wrote:

> 2008/9/8 Edwin Fine <erlang-questions_efine@REDACTED>
>
>> I had this exact issue last night, and this is something like what I did
>> because I knew in advance what the arities would be (for better or worse,
>> IANAEE):
>>
>> mf_to_fun1(M, F) ->
>>     fun(X) -> M:F(X) end.
>>
>> mf_to_fun2(M, F) ->
>>     fun(X,Y) -> M:F(X,Y) end.
>>
>> Ugly but it got the job done. It would be really nice if we could just use
>> fun M:F/A, with all these being variables. Surely it can't be a big step
>> beyond apply(M, F, [Args])?
>>
>
> There is an undocumented BIF that can be called like this
>
> erlang:make_fun(Mod, Name, Arity)
>
> to create a fun.
>
> /Bjorn
>
> --
> Björn Gustavsson, Erlang/OTP, Ericsson AB
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080909/a99e93bb/attachment.htm>


More information about the erlang-questions mailing list