remote execution of funs in shell =/= in erts

Peter-Henry Mander erlang@REDACTED
Wed Nov 24 13:13:49 CET 2004


Hi Robert,

Nope!

This code must be the same and compiled on both nodes:

-module(test_remote).
-export([test/0]).
test()->
   spawn_link('test@REDACTED',
      fun() -> group_leader(whereis(init),self()),
               io:format("wow!~n",[])
      end). 

Otherwise I get this: 

   (test@REDACTED)2> test_remote:test().
   <4592.44.0>
   ** exited: {undef,[{#Fun<test_remote.0.22592216>,[]}]} **

Instead of this:

   (test@REDACTED)3> test_remote:test().
   <4592.45.0>

with the remote node doing this:

   (test@REDACTED)2> wow!

It would seem that the shell sends a self-contained function closure
(lambda) to the remote node, but erts doesn't. I also found out that the
two instances of test_remote must be equivalent on both nodes, otherwise
it fails. i.e. if there's a different version of synonymous modules on
each node, it fails.

Pete.

On Wed, 24 Nov 2004 11:45:14 0000
Robert Raschke <r.raschke@REDACTED> wrote:

> Hi Pete,
> 
> > (test@REDACTED)2> spawn('test@REDACTED',fun() -> group_leader(whereis(init),self()),io:format("wow!~n",[]) end).
> > <4394.54.0>
> > 
> [...snip...]
> > 
> > -module(test_remote).
> > -export([test/0]).
> > test()-> spawn_link('test@REDACTED',fun f/0).
> > f()-> group_leader(whereis(init),self()),io:format("wow!~n",[]).
> > 
> 
> These two are not exactly the same. What happens if you run
> 
> -module(test_remote).
> -export([test/0]).
> test()-> spawn_link('test@REDACTED',fun() -> group_leader(whereis(init),self()),io:format("wow!~n",[]) end).
> 
> ?
> 
> My initial guess would be that the "other" side does not know what f/0 is.
> 
> Robby
> 


-- 
"The Tao of Programming
 flows far away 
 and returns 
 on the wind of morning."




More information about the erlang-questions mailing list