[erlang-questions] escript vs. function

Fernando Benavides <>
Thu Nov 24 16:48:29 CET 2011


Hi all,

Today I've run into a new (to me, at least :P) *tricky situation* in
escript.
Check the following script:

#!/usr/bin/env escript

add1(X) -> X + 1.
> main(_Args) -> lists:map(fun add1/1, lists:seq(1,10)).
>

If you try to run it, it fails with the following message:

escript: exception error: undefined function erl_eval:add1/1


If you try this one instead...

 #!/usr/bin/env escript

add1(X) -> X + 1.
> main(_Args) -> lists:map(fun ?MODULE:add1/1, lists:seq(1,10)).
>

Then you get...

priv/test:3: Warning: function add1/1 is unused
> escript: exception error: undefined function
> test__escript__1322__149559__518984:add1/1
>   in function  lists:map/2
>   in call from erl_eval:local_func/5
>   in call from escript:interpret/4
>   in call from escript:start/1
>   in call from init:start_it/1
>   in call from init:start_em/1


It's not too complicated to work around, but I thought I should share it.
Cheers

*Fernando Benavides <http://google.com/profiles/greenmellon>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20111124/a28c23e3/attachment.html>


More information about the erlang-questions mailing list