[erlang-questions] Compiler to warn on used underscore-variables

Robert Virding rvirding@REDACTED
Tue Jan 5 00:22:04 CET 2010


2010/1/5 Tony Arcieri <tony@REDACTED>

> On Mon, Jan 4, 2010 at 3:55 PM, Robert Virding <rvirding@REDACTED> wrote:
>
>> They *ARE* ordinary variables! All variables are variables irrespective of
>> whether there name starts with a capital letter or an "_". The *ONLY*
>> exception is the variable '_'
>>
>
> This was a really interesting discovery writing Reia, as I soon found out
> the need for variables to begin with a capital letter is solely an effect of
> the parser, and I can create a language with lower case variable names and
> the Erlang compiler has no issue with them.
>

No, internally the compiler doesn't care what the name of a variable is as
long as it is tagged as a variable in the abstract syntax. It is the lint
pass of the compiler which has some knowledge of variables names, whether
they start with "_" or not, and issues warnings about their use. You can
start all variables with an "_" and keep the compiler quiet. Or use an
option.

Robert


More information about the erlang-questions mailing list