Can messages be sent to processes interactively?
Fri May 21 22:53:24 CEST 1999
> I've been doing a lot of sequential programming in Erlang, but have just
> started getting into concurrency. It seems very obvious and
> I wrote a quickie test process so I can start it up and send messages to
> it interactively, just so I know that all is well:
> start() -> spawn(sample, server, ).
> server() ->
> stop -> ok;
> Msg ->
> io:fwrite("message received: ~w\n", [Msg]),
And yet another little error, there is no function
called sample:server/0 nor sample:server/1 *exported*
from the module.
It might seem pretty idiotic that any function that is spawned
need to be exported but that is the way it is.
(applies to apply/3 too !!!)
Personally I like the
switch while I'm developing, this way I need not bother
about that at that stage.
PS. There's a bit of one of my favourite topics in here -- namely
software archeology. Why is it like this. The obvious thing would
be to spawn a fun instead of a tripple M:F/A
spawn(fun() -> server() end).
More information about the erlang-questions