[erlang-bugs] erl rejects FQN that begin with a digit

Robert Virding robert.virding@REDACTED
Thu Oct 21 23:49:20 CEST 2010


----- "Vlad Dumitrescu" <vladdu55@REDACTED> wrote:

> On Wed, Oct 20, 2010 at 14:13, Patrick Baggett
> <baggett.patrick@REDACTED> wrote:
> > -- snip --
> > 2.3  Atom
> > An atom is a literal, a constant with name. 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
> > @.
> > -- snip --
> >  name@REDACTED contains a @, so one would expect if this was a single
> atom, that
> > single quotes would be required, but they aren't. Erlang just
> magically
> > knows, that is, unless you start it with a digit, because when it is
> broken
> > into multiple atoms (I guess?) it fails the test of starting with a
> lower
> > case character.
> 
> It's not the @ that separates the name in multiple atoms, but the
> dots. It's an artifact of the still experimental package feature that
> you can chain atoms together with dots, in the old times one had to
> use quotes for host names.

Sorry, I find that a terrible hack. It is one thing allowing a dot to be an atom character so you can write a.b.c without quoting, but it is another to special case it so it is only an atom character if it is followed by a lowercase letter. And having some sort of auto-concatenate if part of the atom is quoted. I just checked and you get:


9> a.'b'.c.
'a.b.c'
10> a.'b.'c.
* 1: syntax error before: c
10> a'.b'c. 
* 1: syntax error before: '.b'
10> a.'.b'c.
* 1: syntax error before: c
10> a.'.b'.c.
* 1: bad module name 'a..b.c'
11> 'a'.'b'.c.
'a.b.c'
12> 'a''b'.
* 1: syntax error before: b

So it can only be used to quote parts of a dot separated sequence of atoms to build one atom. That is terrible!

Robert


More information about the erlang-bugs mailing list