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

Kevin <>
Fri May 1 07:11:30 CEST 2009


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")



More information about the erlang-questions mailing list