[erlang-questions] leading underscores on variables versus _
Ulf Wiger (TN/EAB)
Fri Feb 2 16:07:42 CET 2007
> 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 above...
A bit more seriously, consider the following code from
yeccpars2(6, ';', __Ss, __Stack, __T, __Ts, __Tzr) ->
yeccpars1(__Ts, __Tzr, 282, [6 | __Ss], [__T | __Stack]);
So making the change would require a change in yecc at
the same time. Code wouldn't break unless recompiled with
new underscore semantics, but a yecc that hadn't been
modified to match.
Of course it begs the question whether there isn't
other code as well that uses the same convention.
In jungerl, I found that plain_fsm (by me) and
eradius (by Martin B.) also reference __X type variables.
It's reasonable to assume that there is more code out
there that would break.
More information about the erlang-questions