[erlang-questions] bug in escript and a question

Lars Thorsen lars@REDACTED
Tue Oct 5 13:39:53 CEST 2010


You can't have Erlang code on the first line in an escript, here are some lines from the man page ;).

--------------------------------
The header of the Erlang script in the example differs from a normal Erlang module. The first line is intended to be the 
interpreter line, which invokes escript. However if you invoke the escript like this

$ escript factorial 5

the contents of the first line does not matter, but it cannot contain Erlang code as it will be ignored.

The second line in the example, contains an optional directive to the Emacs editor which causes it to enter the major 
mode for editing Erlang source files. If the directive is present it must be located on the second line.

On the third line (or second line depending on the presence of the Emacs directive), it is possible to give arguments to 
the emulator, such as

%%! -smp enable -sname factorial -mnesia debug verbose

Such an argument line must start with %%! and the rest of the line will interpreted as arguments to the emulator.
-------------------------------


///Lars


Joe Armstrong wrote:
> This escript fails
> 
> 
>  +-------------------------------------
>     -record(b,{this=that}).
> 
>     main(_) ->
>        io:format("B=~p~n",[#b{}]),
>        halt(1).
>   +-----------------------------------
> 
> The code is between the lines marked +------
> 
> This is what happens
> 
> $ escript b 12
> b:3: record b undefined
> escript: There were compilation errors.
> 
> If you add a single blank or comment before the record declartion then it works
> 
>  +-------------------------------------
>    %% comment
>     -record(b,{this=that}).
> 
>     main(_) ->
>        io:format("B=~p~n",[#b{}]),
>        halt(1).
>   +-----------------------------------
> $ escript b 12
> B={b,that}
> joe@REDACTED:~/work/c_compiler/bic_current/src$
> 
> Now it works
> 
> Also -include(..) just doesn't work but -include_lib(...) does.
> I cannot think why this should be so - is there any good reason for this?
> I can't think of one.
> 
> Cheers
> 
> /Joe
> 
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:erlang-questions-unsubscribe@REDACTED
> 



More information about the erlang-questions mailing list