[erlang-questions] Closures vs apply

Joel Reymont <>
Mon Jul 16 21:40:44 CEST 2007


I have code that looks like this

wrap(F) ->
     case catch F of
         {'EXIT', Error} ->
             {abort, Error};
         Any ->
             Any
     end.

db_put(Tab, Val) ->
     wrap(fun() -> s3:put_data(bucket(Tab),
                               term_to_binary(element(2, Val)),
                               "octet/stream",
                               term_to_binary(Val),
                               "")
          end).

I wonder if db_put is better written as apply(s3, put_data, [args  
here]).

Would this be more or less expensive than using a closure?

	Thanks, Joel

--
http://topdog.cc      - EasyLanguage to C# compiler
http://wagerlabs.com  - Blog








More information about the erlang-questions mailing list