[erlang-questions] passing function references, do we have same ability as bifs?

Bernard Duggan <>
Fri May 1 07:41:42 CEST 2009


Hi Kevin,
    Have a look at erlang:apply().

Cheers,

Bernard

Kevin wrote:
> I've figured out how to do this simple "meta-programming",
>
> start() ->
>     run(io, format, ["hello", "there"]).
>
>
> run(M, F, Args) ->
>     M:F("~s ~s~n", Args).
>
>
> But do we have the same power as something like spawn(Module, Function, 
> Args), where Args is
> passed in as a list, but its "exploded" into parameters when the 
> function is called?
>
> Can something like this work?
>
>
> start() ->
>     run(string, equal, ["hello", "hello"]).
>
>
> run(M, F, Args) ->
>     M:F(Args).  %% called as string:equal("hello", "hello")
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>   




More information about the erlang-questions mailing list