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?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With