tags:

views:

59

answers:

1

I start a process as follows

start() ->
register (dist_erlang, spawn(?MODULE, loop, [])),
ok.

But get the following error when trying to run start().

Error in process <0.62.0> with exit value: {undef,[{dist_erlang,loop,[]}]}

The module is called dist_erlang.

What am I doing wrong?

Thanks

+5  A: 

Based on your previous question, your loop function takes one parameter, not none. Erlang is looking for loop/0 but can't find it because your function is loop/1.

The third parameter to spawn/3 is a list of parameters to pass to your function, and in the case you've shown the list is empty. Try:

register (dist_erlang, spawn(?MODULE, loop, [[]]))

In this case, the third parameter is a list that contains one element (an empty list).

Greg Hewgill
I really appreciate your help. Thanks :)
alJaree