[erlang-questions] Newbie question: is there something like a main() method in Erlang?

Julian Fondren <>
Sat Apr 28 07:59:01 CEST 2007


On 4/28/07, jm <> wrote:
> Harish Mallipeddi wrote:
> > Anyways I'm wondering if there's like a main() method in Erlang which
> > will run automatically? Currently from the examples I've been coming
> > across in the book and online, you've to create a new module and then go
> > to the Erlang shell and do c('module_name') to compile/load the module.
> > Is there a way to just say "erl module.beam" and have it invoke some
> > method automatically much like how if __name__=="__main__" works in
> Python.
>
> One last
> thought take a look at something like yaws to see how it's put together.

(edited)

Yaws uses a shell script to figure out the arguments and then invoke
something more involved than: erl -s yaws init args

Anyway, http://wiki.trapexit.org/index.php/Hello_World gives you
three ways to do this and also some "don't do that" propaganda.
Erlang is just much more interesting when you -don't- treat it
like Python.

You could go the other way and build everything with Makefiles,
having the Makefile also generate yaws-style wrappers for each
of your programs.

Cheers,
Julian



More information about the erlang-questions mailing list