Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Naming nodes in Erlang

Tags:

erlang

I'm playing with the distributed programming tutorial from the 5.4 documentation, and have run into a problem with node names.

My MacBook's default name (jamess-macbook) does not play well with Erlang's node-naming scheme, due to the dash:

(salt@jamess-macbook)4> {my_process, pepper@jamess-macbook} ! start
** exception error: bad argument in an arithmetic expression
     in operator  -/2
        called as pepper@jamess - macbook

I'm sure there's an easy way to get around this, short of renaming all the machines I want to run Erlang on, but I can't see it in the documentation.

Any suggestions?

like image 546
James Brady Avatar asked Jan 05 '09 16:01

James Brady


1 Answers

You just need to quote the atom properly. 'pepper@jamess-macbook' (with the single quotes) is the name of the node.

An atom should be enclosed in single quotes (') if it does not begin with a lower-case letter or if it contains other characters than alphanumeric characters, underscore (_), or @. -- Erlang Reference Manual

Using short node names (-sname) has various other consequences (limited interoperability with long node name nodes, doesn't load dns information into inet_db and so on).

like image 187
archaelus Avatar answered Sep 18 '22 03:09

archaelus