Sorry I did not give a good explanation of what I try to do. I would like to write the function "wrap_fun" so that I can call it with different inner functions. Let say I have different functions:<br>compute_one/1
<br>compute_two/2<br>I would like to be able to write:<br>Log_compute_one = wrap_fun(compute_one, logger),<br>Log_compute_two = wrap_fun(compute_two, logger).<br><br><br><div><span class="gmail_quote">On 11/18/06, <b class="gmail_sendername">
t ty</b> <<a href="mailto:tty.erlang@gmail.com">tty.erlang@gmail.com</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Unfortunately I'm not very sure what you need. You can always encode<br>all the params into a list also funs can also take multi params<br><br>wrap_fun(Fun, Pid) -><br> fun(One, Two, Three) -><br> Res = Fun(One, Two, Three)
<br> Pid ! Res<br> end.<br><br>t<br><br>On 11/17/06, Ludovic Coquelle <<a href="mailto:lcoquelle@gmail.com">lcoquelle@gmail.com</a>> wrote:<br>> I would like to wrap a function into another which send the the result of
<br>> the inner function to some external process.<br>> Let say I have a function called "compute" and a log process "logger": I<br>> want to create a new function with something like:<br>>
<br>> Log_compute = wrap_fun(compute, logger).<br>><br>> wrap_fun(Fun, Pid) -><br>> fun(AllArgs) -><br>> Res = Fun(AllArgs),<br>> Pid ! Res<br>> end.<br>><br>> But I don't know how to do that with a function of any arity (the code above
<br>> work only for function of arity 1).<br>> Is this do-able? if not, how should I do?<br>><br>><br>> _______________________________________________<br>> erlang-questions mailing list<br>> <a href="mailto:erlang-questions@erlang.org">
erlang-questions@erlang.org</a><br>> <a href="http://www.erlang.org/mailman/listinfo/erlang-questions">http://www.erlang.org/mailman/listinfo/erlang-questions</a><br>><br>><br>><br></blockquote></div><br>