Anonymous function and rpc

Jérôme Sautret jerome.sautret@REDACTED
Tue May 30 17:16:31 CEST 2006


2006/5/24, Vlad Dumitrescu XX (LN/EAB) <vlad.xx.dumitrescu@REDACTED>:
> > [mailto:owner-erlang-questions@REDACTED] On Behalf Of Jérôme Sautret
> >
> > Hello all,
> >
> > Is it possible to pass an anonymous function as a parameter
> > of a function called by rpc ?
> > The strange thing is I can do it in the BEAM shell, but not
> > in a module :
> >
> > % erl -sname debug
> > Erlang (BEAM) emulator version 5.4.6 [source] [threads:0]
> >
> > Eshell V5.4.6  (abort with ^G)
> > (debug@REDACTED)1> rpc:call(debug2@REDACTED, mnesia, transaction,
> > [fun() -> ok end]).
> > {atomic,ok}
> > (debug@REDACTED)2> mydebug:mydebug().
> > {aborted,{undef,[{#Fun<mydebug.0.39827269>,[]},
> >                 {mnesia_tm,apply_fun,3},
> >                 {mnesia_tm,execute_transaction,5},
> >                 {rpc,'-handle_call/3-fun-0-',5}]}}
> > (debug@REDACTED)3> q().
> > ok
> > % cat mydebug.erl
> > -module(mydebug).
> > -export([mydebug/0]).
> >
> > mydebug() ->
> >    rpc:call(debug2@REDACTED, mnesia, transaction, [fun() -> ok end]).
> >
> > % EOF
> > %
> Hi,
>
> I think that you have to have the same version of mydebug installed on the remote host. The shell does some magic stuff under the covers :-)
>
> /Vlad

Thanks for the answer, it works now. I've used a rpc call on
code:load_binary to send my function on the remote node. Well, too bad
that the magic stuffs aren't include in the rpc call ;-).

Jérôme.



More information about the erlang-questions mailing list