[erlang-questions] dumb question from rookie

envelopes envelopes sunwood360@REDACTED
Wed Mar 7 03:49:42 CET 2012

cool,  ==> erl -pa apps/dummy/ebin -eval 'dummy_app:start(25,30)'  works.

Another workaround is adding one extra start/0 function, like :

start() -> dummy_sup:start_link().

then both ==> erl -pa apps/dummy/ebin -s dummy_app and ==> erl -pa
apps/dummy/ebin -s dummy_app start  worked.

On Tue, Mar 6, 2012 at 12:53 PM, Tim Watson <watson.timothy@REDACTED>wrote:

> On 6 Mar 2012, at 16:39, envelopes envelopes wrote:
> On Mar 6, 2012 2:11 AM, "Tim Watson" <watson.timothy@REDACTED> wrote:
> >
> > Hi there,
> >
> > I'm not sure about this second issue (of the _app module not being
> loaded in the shell) but I can explain the former. When you run the 'erl'
> program with -s you are telling the built in 'init' module to run the
> following module, function with optional arguments. When you pass '-s
> mysample_app start' you are telling the init module to call that function,
> but 'init' is a special module, part of the runtime system. Your module
> isn't special, so the code server hasn't loaded it yet and 'init' can't
> find it so it is 'undefined' hence the error message.
> how come ' erl -pa ebin -s mysample_app main 23' works? If the code server
> has not loaded it yet. The behavior is not consistent.
> My mistake I withdraw my original explanation as it was completely wrong.
> Ryan was correct it is due to the arity of your function. In the 'erl'
> documentation:
> "... If no arguments are provided, the function is assumed to be of arity
> 0. Otherwise it is assumed to be of arity 1, taking the list
> [Arg1,Arg2,...] as argument. "
> If you want to pass more than one argument on startup, you'll need to use
> -eval instead: 'erl pa ebin -eval 'prototype_app:start(25, 30)'
> My misdirection notwithstanding, the idiomatic way to start an application
> is to either put it in a release or to pass '-s application start <myapp>'
> rather than call the module's start/2 function explicitly.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120306/f11f800f/attachment.htm>

More information about the erlang-questions mailing list