[erlang-questions] escript vs. function

Håkan Mattsson hm@REDACTED
Thu Nov 24 17:07:55 CET 2011


Try with adding this compiler directive:

-mode(compile).

/Håkan

On Thu, Nov 24, 2011 at 4:48 PM, Fernando Benavides
<fernando.benavides@REDACTED> wrote:
> 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
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>
>



More information about the erlang-questions mailing list