[erlang-questions] -pidname( <atom> ) Was: Why we need a -module() attribute?
Fri Feb 26 16:21:23 CET 2016
I suggested something similar years ago.
I think there should be a process declaration (analogous) to -module(Name)
The main reason is linguistic. We cannot talk about 'the process foo'
or 'a foo process'.
Processes don't have names so we can't about them, instead we have to
use a linguistic circumlocution. Instead of saying " a foo process" we
have to say "a process started by evaluating spawn(foo, ....)"
I suggest two alternatives:
start(Args) -> ... end
start_one(Args) -> ...
The primitive spawn should be removed and replaced with
Pid = create_process foo(Args) which would equivalent to
spawn(foo, start, Args)
register should be removed and replaced with
create_global foo(Args) which would be equivalent to
register(foo, spawn(foo, start_one, Args))All
All this can be done with simple preprocessing :-)
On Fri, Feb 26, 2016 at 7:02 AM, Valentin Micic <> wrote:
> Almost all process registrations should be local to the module that
> them. I proposed
> for declaring a module-locale atomic variable to hold pids. This would be
> safer than the global registry and more efficient. The global registry
> remain for those things that genuinely need to be global.
> Presuming that the module name is , say, test, how is:
> -pidname( test )
> different from:
> register( ?MODULE, self() )?
> Also, how would you run multiple instances of the same module within the
> same run-time?
> Your proposal may appear to solve one problem (that is, if one chose to call
> it a problem), but appears to introduce at least one more.
> erlang-questions mailing list
More information about the erlang-questions