Erlang/OTP Forums

Author Message

<  Erlang  ~  starting a process

phicarre
Posted: Fri Mar 27, 2009 4:44 pm Reply with quote
User Joined: 23 Mar 2009 Posts: 14
which is the difference between the following instructions ?
spawn(?module,process(arguments))
spawn(?module,process,[arguments])

The second one gives me a compilation error: process is unused and a run-time error: error in process P on node N with exit value: {undef,[{module,process,[...]}]}


Last edited by phicarre on Fri Mar 27, 2009 5:17 pm; edited 1 time in total
View user's profile Send private message
keymone
Posted: Fri Mar 27, 2009 4:56 pm Reply with quote
User Joined: 17 Sep 2007 Posts: 11 Location: Lviv, Ukraine
spawn(?MODULE, process(Arguments)) - this is wrong, you probably want to do this:

spawn(?MODULE, process, [Arguments]) - this is correct spawn call but you need to export process function:

-export([process/number_of_arguments]).

the error you get is actually a warning and it means you defined process function but never exported it.
View user's profile Send private message MSN Messenger ICQ Number
phicarre
Posted: Fri Mar 27, 2009 10:45 pm Reply with quote
User Joined: 23 Mar 2009 Posts: 14
But that runs !
View user's profile Send private message
keymone
Posted: Mon Mar 30, 2009 6:32 am Reply with quote
User Joined: 17 Sep 2007 Posts: 11 Location: Lviv, Ukraine
there is only 1 definition of spawn/2 described in documentation: http://www.erlang.org/doc/man/erlang.html#spawn-2

spawn(Node, Fun) -> pid()

in your case it means

?MODULE should return correct Node name and
process(Arguments) should return a fun

otherwise you'll run into runtime error

if it does runs you should provide some code because i have no idea how should it look like to make that spawn/2 work correctly
View user's profile Send private message MSN Messenger ICQ Number

Display posts from previous:  

All times are GMT
Page 1 of 1
This forum is locked: you cannot post, reply to, or edit topics.

Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum