[erlang-questions] On Per-module process registration

Richard O'Keefe ok@REDACTED
Thu Feb 11 03:44:03 CET 2010

On Feb 11, 2010, at 2:47 PM, Fred Hebert wrote:

> I've been reading the EEP and trying to grasp it, but this very post  
> really made me grasp what you wanted.

I'm sorry I explained it so badly in the first place.
> This works when you want to address a particular part of a group of  
> processes from the outside, but one of the concerns I have with that  
> is that the supervisor's children who need to access the registry to  
> communicate between themselves then need to be aware of the  
> supervisor's presence and the names which are given there. It sounds  
> like an indirect circular dependency Erlang programs could do without.

Oh, agreed.  But the circularity _exists_.  Do it with a dynamically
created registry (should such a thing exist), and
  - the processes have to know about the registry
  - the registry exists to know about the processes

In other contexts I've resorted to

	Pids = spawn a bunch of new processes,
	Info = some information derived from them that they
                need to share,
         [Pid ! {info,Info} || Pid <- Pids]

where the first thing each new process does is
	receive {info,Info} -> ...

For example, set up a grid of processes, then tell each process
what its neighbours are (West -> East, but also West <- East).
Indirection is the only way we _can_ break cycles in Erlang.

Of course cycles are always something to beware of.


More information about the erlang-questions mailing list