help!

Ulf Wiger <>
Fri Feb 16 15:51:43 CET 2001


Hi!

You use the -module(...) notation when writing a program.
It is what is called a "compiler directive". It is only 
useful in a program file.

What you are doing below is entering commands in the interactive
Erlang shell. Here, you can call functions, evaluate expressions,
and even assign values to variables, but you cannot use compiler
directives.

If you want to create a module named demo, create a file called
demo.erl. At the top of the file, write "-module(demo)."
Then you need to add an "-export(...) directive to be able to 
call functions from the outside.

  -module(demo).
  -export([foo/0]).


  foo() ->
      hello.

Finally you compile demo.erl. You can do this from the interactive
shell:

  1> c(demo).
  {ok, demo}

Then you can call your exported functions:

  2> demo:foo().
  hello


/Uffe

On Fri, 16 Feb 2001, Joao Jr. wrote:

>Hi, I'm beginner in erlang.
>
>I can't use module in erlang, always return message error like:
>
>
>
>Erlang (BEAM) emulator version 5.0.1 [threads]
>
>Eshell V5.0.1 (abort with ^G)
>
>1> -module(demo).
>
>** exited: {undef,[{shell_default,module,[demo]},
>
>{shell,local_func,4},
>
>{erl_eval,expr,3},
>
>{erl_eval,exprs,4},
>
>{shell,eval_loop,2}]} **
>
>2>
>
>What can I do?
>
>Thanks, Joao Jr.
>
>

-- 
Ulf Wiger                                    tfn: +46  8 719 81 95
Senior System Architect                      mob: +46 70 519 81 95
Strategic Product & System Management    ATM Multiservice Networks
Data Backbone & Optical Services Division      Ericsson Telecom AB




More information about the erlang-questions mailing list