remote execution of funs in shell =/= in erts

Peter-Henry Mander <>
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('',
      fun() -> group_leader(whereis(init),self()),
               io:format("wow!~n",[])
      end). 

Otherwise I get this: 

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

Instead of this:

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

with the remote node doing this:

   ()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 <> wrote:

> Hi Pete,
> 
> > ()2> spawn('',fun() -> group_leader(whereis(init),self()),io:format("wow!~n",[]) end).
> > <4394.54.0>
> > 
> [...snip...]
> > 
> > -module(test_remote).
> > -export([test/0]).
> > test()-> spawn_link('',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('',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