lauantaina, kesäkuuta 14, 2008

Erlang process spawning

I'm a bit puzzled about Erlang process spawning. Why does spawn/1 exist? Let me explain.

The normal way to spawn a process is apparently with spawn/3 (which means that spawn takes 3 arguments): spawn(Module, Function, Argumentlist). A "module" in Erlang means the file in which the function is specified.

There is also a variant of spawn that takes only one parameter, spawn/1: spawn(Function). It starts a process running that function with no parameters. One could easily think it is a shorthand for spawning a process that runs a function defined in the same module where spawn was called, but I have never gotten it to work.

When I try spawn/1 in my first Erlang program, all I get is this error: {"init terminating in do_boot",{badarg,[{erlang,spawn,[pinger]},{pingpong,start_pings,1},{init,start_it,1},{init,start_em,1}]}}

Anyone have any ideas?

Ei kommentteja: