[erlang-questions] -pidname( <atom> ) Was: Why we need a -module() attribute?

Joe Armstrong erlang@REDACTED
Fri Feb 26 16:21:23 CET 2016


Yes !

I suggested something similar years ago.

I think there should be a process declaration (analogous) to -module(Name)

Something like

    -process(foo).

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:

    -process(foo).

    start(Args) -> ... end

And

    -process(foo)

    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 :-)

Cheers

/Joe



On Fri, Feb 26, 2016 at 7:02 AM, Valentin Micic <valentin@REDACTED> wrote:
> Almost all process registrations should be local to the module that
> registers
> them.  I proposed
>
>      -pidname(<atom>).
>
> for declaring a module-locale atomic variable to hold pids.  This would be
> both
> safer than the global registry and more efficient.  The global registry
> would
> 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.
>
> V/
>
>
>
> _______________________________________________
> erlang-questions mailing list
> erlang-questions@REDACTED
> http://erlang.org/mailman/listinfo/erlang-questions
>



More information about the erlang-questions mailing list