Search code examples
stringshellvariableserlangquote

Erlang: is a name without double quotes, still a string or something else?


I'm new to Erlang, just tried the shell:

Eshell V8.2  (abort with ^G)
1> Hello=hello.
hello
2> Hello.
hello
3> Point={point,10,45}.
{point,10,45}
4> Point2={"point",10,45}.
{"point",10,45}

In Point, the first element is 'point', there's no variable named point so it's not a reference, there's no double "", so it's not a string. But shell doesn't report any error.

So what is it?


Solution

  • It is an atom. From the documentation:

    Is a literal, a constant with name. 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 @_

    So point it's a valid Erlang term. Same idea applies to hello too.