escript vs erl

Andrew Pennebaker <>
Wed Feb 23 23:45:06 CET 2011


When I run my Erlang scripts with escript, threads throw an undef error when
trying to call themselves recursively.

E.g.

loop() ->
   io:format("Looping~n"),

   receive
   after
      3 -> loop()
   end.

main(_) ->
   spawn(loop, loop, []).

$ escript loop.erl

=ERROR REPORT==== 23-Feb-2011::17:18:05 ===
Error in process <0.30.0> with exit value: {undef,[{loop,loop,[]}]}

The mitigation is to run erl and compile loop.erl into loop.beam before
running.

$ erl
1> c(loop).
2> q().
$ escript loop.erl
Looping
Looping
Looping
...

Could Erlang be modified so that recursive functions work interactively with
escript, rather than requiring explicit compilation first?

Specs:

Erlang R14B01
MacPorts 1.9.2
Mac OS X 10.6.6
MacBook Pro 5,1

Cheers,
Andrew Pennebaker


More information about the erlang-questions mailing list