[erlang-questions] Convert atom and arity into fun

Edwin Fine erlang-questions_efine@REDACTED
Mon Sep 8 14:49:58 CEST 2008


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])?

On Mon, Sep 8, 2008 at 12:59 AM, Richard A. O'Keefe <ok@REDACTED>wrote:

> On 5 Sep 2008, at 10:45 pm, Richard Carlsson wrote:
> > There is currently no immediate way of doing this.
>
> We have the "fun <name>/<arity>" notation, which I believe
> has been extended or will be extended to "fun <module>:<name>/<arity>".
> It would seem like a minor change to the language to allow
> variables here.
>
> It must be said, this looks like a case for the
> old-fashioned {M,F} or {M,F,A} tuples-naming-functions.
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://www.erlang.org/mailman/listinfo/erlang-questions
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20080908/fe1a2262/attachment.htm>


More information about the erlang-questions mailing list