[erlang-questions] escript vs erl

Andrew Pennebaker andrew.pennebaker@REDACTED
Sun Mar 6 22:29:16 CET 2011


That helps with a recursive call within a module. But try this:

scriptedmain.erl:

-module(scriptedmain).
-mode(compile).
-export([meaning_of_life/0]).
-import(lists, [map/2]).

meaning_of_life() -> 42.

main(_) ->
io:format("Main: The meaning of life is ~w~n", [meaning_of_life()]).

test.erl:

-module(test).
-import(scriptedmain, [meaning_of_life/0]).

main(_) ->
io:format("Test: The meaning of life is ~w~n", [meaning_of_life()]).

$ escript scriptedmain.erl
Main: The meaning of life is 42
$ ls *.beam
ls: *.beam: No such file or directory
$ escript test.erl
escript: exception error: undefined function scriptedmain:meaning_of_life/0

(When -mode(compile) is added to test.erl)

$ escript test.erl
escript: exception error: undefined function scriptedmain:meaning_of_life/0
  in function  test_erl__escript__1299__446882__865649:main/1
  in call from escript:run/2
  in call from escript:start/1
  in call from init:start_it/1
  in call from init:start_em/1

Cheers,

Andrew Pennebaker
www.yellosoft.us



On Wed, Feb 23, 2011 at 6:46 PM, Yurii Rashkovskii <yrashk@REDACTED> wrote:

> Another option is to specify
>
> -mode(compile).
>
> and in your spawn/3 code use ?MODULE for module
>
>
>
>
> ________________________________________________________________
> 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