ensure_started
Ulf Wiger
etxuwig@REDACTED
Mon Mar 24 13:03:39 CET 2003
On Mon, 24 Mar 2003, Joe Armstrong wrote:
>I often wonder why we made spawn/3 a primitive and not just
>spawn a "universal" empty process and then send it a
>message telling it what to do.
>
>
> Pid = spawn()
> Pid ! Fun()
>
>where
>
> spawn() ->
> spawn(fun() ->
> receive
> Fun ->
> Fun()
> end
> end).
>
> This is particularly useful when you need to setup sets
>of mutually recursive processes, then you can say:
>
> Pid1 = spawn()
> Pid2 = spawn(),
> Pid1 ! fun() -> ... Pid2 ... end,
> Pid2 ! fun() -> ... Pid1 ... end,
>
> /Joe
Interesting... but how long should a universal process live
before it gives up waiting for a fun thing to do?
Or should empty unreferenced processes be garbage-collected?
This would require a unified heap, or reference-counted
pids. Oh well, nothing that couldn't have been solved. (:
BTW, the reason you didn't do this from the beginning was
that Erlang didn't have funs back then. ;-)
/Uffe
--
Ulf Wiger, Senior Specialist,
/ / / Architecture & Design of Carrier-Class Software
/ / / Strategic Product & System Management
/ / / Ericsson AB, Connectivity and Control Nodes
More information about the erlang-questions
mailing list