[erlang-questions] Sending funs between nodes

Kirill Zaborski qrilka@REDACTED
Wed Aug 29 21:28:33 CEST 2007


I was trying to do the following:
1) a module on node X -
-------------------
-module(test1).
-export([go/0]).

go() ->
P = spawn(fun() -> receive X -> X() end end),
register(rrr, P).
-------------------
2) a module on node Y -
-------------------
-module(test2).
-export([go/0]).

go() ->
{rrr, x@REDACTED}!fun() -> io:format("bar",[]) end.
-------------------

LOKI is my hostname :)

So If I run test1:go() and then test2:go() on other node I get

=ERROR REPORT==== 29-Aug-2007::22:34:29 ===
Error in process <0.35.0> on node 'y@REDACTED' with exit value:
{undef,[{shell_defau
lt,fun_to_list,[#Fun<erl_eval.20.62269157>]},{erl_eval,do_apply,5},{shell,exprs,
6},{shell,eval_loop,3}]}

** exited: {undef,[{shell_default,fun_to_list,[#Fun<erl_eval.20.62269157>]},
                   {erl_eval,do_apply,5},
                   {shell,exprs,6},
                   {shell,eval_loop,3}]} **

It looks like fun needs code of the module where it was defined. Why is it
so?
is there any way around this issue? Or I need the same beams on all the
nodes?


Best regards,
Kirill Zaborski.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20070829/ee586ac3/attachment.htm>


More information about the erlang-questions mailing list