[erlang-questions] Re: register BIF

Scott Lystig Fritchie <>
Tue Mar 15 23:10:23 CET 2011

Wes James <> wrote:

wj> register(timer2, timer2:timeout(0,0)) and it worked.  The first
wj> timer2 is the module name.  I guess it wants the module name to
wj> register, not just any atom.

Wes, that's incorrect: register/2's first arg can be any atom.  But you
can't register the same name twice ... even if it's the same process
that is trying the second time.

    1> code:which(file).         
    2> code:which(asdlkfklasdfljkasdfjlkasdf).
    3> self().
    4> register(asdlkfklasdfljkasdfjlkasdf, self()).
    5> self().                                      
    6> register(asdlkfklasdfljkasdfjlkasdf, self()).
    ** exception error: bad argument
         in function  register/2
            called as register(asdlkfklasdfljkasdfjlkasdf,<0.32.0>)


More information about the erlang-questions mailing list