[erlang-questions] leading underscores on variables versus _
Richard A. O'Keefe
ok@REDACTED
Tue Feb 6 23:59:17 CET 2007
Matthias Lang <matthias@REDACTED> wrote:
Changing _x to behave as many (most?) initially expect would break
backwards compatibility, but only for misleading code such as the
above...
Wrong.
Cast your mind back to 1986 and consider someone writing
Quintus Prolog in Japanese. All Japanese characters were
taken to be LOWER case, so that they could be used for
atoms and predicate names.
Japanese programmers would surely like to write Erlang
function names using their own language and script, no?
But that means that a variable name cannot begin with a
Japanese character. That's fine, Japanese Prolog programmers
thought of the convention as "to name a variable, put an
underscore in front of a word or phrase".
Japanese programmers would surely like to name Erlang
variables using their own language and script, not?
So there HAS to be a way of writing a variable name that does not
involve starting it with a Latin capital letter, and that way is
to use an underscore. 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.
I note that Prolog, Mercury, Clean, and Haskell all use "_" for
anonymous variables, and none of them has rule about other variable
names starting with "_" being unusual, and now you know one reason
why they don't.
More information about the erlang-questions
mailing list