[erlang-questions] Newbie question: function include/1 undefined

Richard A. O'Keefe ok@REDACTED
Mon Oct 3 05:14:11 CEST 2016


(1) Your initialisation code can return a tuple or list of process IDs.

(2) Your initialisation code can store the process IDs in the
     process dictionary.  Each process has its own dictionary.

     Self = self(),
     Orbiter1 = spawn(fun () -> orbiter:start(Self, data(1) end),
     ...
     Orbiter16 = spawn(fun () -> orbiter:start(Self, data(16) end),
     put(orbiter1, Orbiter1),
     ...
     put(orbiter16, Orbiter16),
     ...
     or even

     Self = self(),
     put(orbiters, [spawn(fun () -> orbiter:start(Self, Data) end)
                   || Data <- orbiter_data()])

(3) You could use the (per-node) global process registry in the
     initialisation code

     register(orbiter1, spawn(fun () -> ... end)),
     ...

     and then use orbiter1!Message later.

This seriously looks like code that could be in another module
without any preprocessor use at all.




More information about the erlang-questions mailing list