Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Erlang atoms and ".."

Tags:

erlang

This is output of erlang shell:

1> atom.
atom
2> next_atom.
next_atom
3> atom@erlang.
atom@erlang
4> 'atom in single quotes'.
'atom in single quotes'
5> atom = 'atom'.
atom
6> a.tom.
'a.tom'
7> a..tom.
* 1: syntax error before: '..'

When there is just one dot . within atom (line 6), I get no errors. However, when there is .., I get syntax error. Does .. have some special meaning in Erlang or why do I get error when . works fine?

like image 383
juro Avatar asked Jun 05 '12 11:06

juro


People also ask

How do I use atoms in Erlang?

An atom is to 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 @. The following program is an example of how atoms can be used in Erlang. This program declares 3 atoms, atom1, atom_1 and ‘atom 1’ respectively.

How many times can an atom string literal be stored?

There is a (erlang runtime instance-) atom table. Atom string literal is only stored once. Atoms take 1 word. To me, this leaves a lot of things in the unclear. Is the atom word value always the same, independent of the sequence modules are loaded into a runtime instance?

What are the relational operators available in Erlang?

Following are the relational operators available in Erlang. Checks to see if the left object is less than the right operand. Checks to see if the left object is less than or equal to the right operand. Checks to see if the left object is greater than the right operand.

What is an arithmetic operator in Erlang?

An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. Erlang language supports the normal Arithmetic operators as any the language.


1 Answers

Dots are not allowed as such in atoms, but a dot between two atoms: 'foo'.'bar', is a compile time operator that concatenates the atoms to 'foo.bar'.

This is an extension which was made to support the (still not officially supported) Java-like package system. That's why it's not documented.

like image 108
tofcoder Avatar answered Sep 28 '22 07:09

tofcoder