remote execution of funs in shell =/= in erts

Matthias Lang matthias@REDACTED
Thu Nov 25 20:43:33 CET 2004

Peter-Henry Mander writes:

 > So I guess that there's a difference between how the shell executes
 > remote funs and how the Erlang runtime executes remote funs. How do
 > nodes communicate what appears to be version information or beam digest
 > or checksums beween them? Is this documented (otherwise than by reading
 > code :-)? 

There are quite a few questions there. I don't know enough about the
ERTS internals to answer all of them confidently, but I'll have a go.

Yes, there's a difference between funs made in the shell and funs made
in code. An easy way to see that is to run term_to_binary() on the
'same' fun made two different ways:

8> io:fwrite("~w", [term_to_binary(e:a())]).              
9> io:fwrite("~w", [term_to_binary(fun(X) -> 2 * X end)]). 

(e:a() is the 'same' fun as the one I entered in the shell).

Taking a quick look at the source (erl_fun.h), it appears that a
'normal' fun includes an MD5sum of the module which created it, which
tallys with your observations. Taking an educated guess, a 'shell fun'
is actually a parse tree.

I would be surprised if it's possible to execute a compiled fun
without making the exact same code available at the other node, but
you don't necessarily have to do that via a filesystem.

 > Is it possible for the runtime to execute a remote fun without
 > the corresponding beam being available on the remote node, like the
 > shell appears to do?

I don't think there's a clean way of doing it. One dirty way is to use
erl_scan, erl_parse and erl_eval. I'd guess that's what the shell


More information about the erlang-questions mailing list