[erlang-questions] leading underscores on variables versus _
Fri Feb 2 15:14:09 CET 2007
Ulf Wiger writes:
> Underscores are always ignored. The variables that begin
> with an underscore are actually real variables. The
> linter interprets them as "don't care" patterns, but the
> compiler does not.
This seems to catch many or even most beginners. It seems natural (?)
to expect _name to be a longer way of writing _, i.e. that any
variable starting with _ means exactly the same thing as if you'd just
An example where that doesn't hold:
f(_x, _x) -> same;
f(_,_) -> different.
Changing _x to behave as many (most?) initially expect would break
backwards compatibility, but only for misleading code such as the
More information about the erlang-questions