[erlang-questions] Closures vs apply

igwan <>
Tue Jul 17 00:13:09 CEST 2007


Hi,

 From the Efficiency Guide 
http://www.erlang.org/doc/efficiency_guide/functions.html#3.2 :
fun calls are about 3 times less expensive than apply(M,F,A)

igwan

Joel Reymont a écrit :
> 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
>
>
>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions
>   




More information about the erlang-questions mailing list