[erlang-questions] leading underscores on variables versus _

Matthias Lang matthias@REDACTED
Wed Feb 7 09:54:03 CET 2007


Richard A. O'Keefe writes:

 > It is ESSENTIAL that leading underscores NOT cause any special
 > treatment; in particular it is essential that they should not cause
 > identifiers to be treated as anonymous variables.

Leading underscores get special treatment in the _current_ Erlang
implementation. The Erlang spec explicitly recommends that behaviour
(last paragraph of "3.16 Variables").

Losing the unused variable warning probably isn't that much of an
issue for most people. Maybe that's why there haven't been any
complaints on the mailing list about it. Or perhaps you're
overestimating the popularity and importance of Japanese identifiers
with leading underscores.

In any case, as already posted, I'm already convinced that making _x
the same as _ causes (far) more trouble than it's worth.

---

While looking at 3.16, I think I found an omission. The first sentence
is:

   A variable is a nonempty sequence of Erlang letters, Erlang digits
   and the character '@', where the first character must be an 
   uppercase Erlang letter.

The grammar which follows in that subsection is complete, but the above
sentence leaves out _ altogether.

Matthias



More information about the erlang-questions mailing list