[erlang-questions] Inconsistent shadowing of variables in a fun
Richard A. O'Keefe
ok@REDACTED
Mon Jan 30 00:17:56 CET 2017
On 30/01/17 11:06 AM, Robert Virding wrote:
> When defining a fun the shadowing of variables occurring in arguments is
> inconsistent.
>
> Why the difference? Shouldn't we be consistent in shadowing all variables?
I have always wished that Erlang did no shadowing at all.
a(X) ->
case X+1 of X -> ooh ; _ -> ahh end.
b(X) ->
(fun (X) -> ooh ; (_) -> ahh end)(X+1).
2> foo:a(0).
ahh
3> foo:b(0).
ooh
Call *that* consistent? I don't.
1> c(foo).
foo.erl:8: Warning: this clause cannot match because a previous clause
at line 8 always matches
foo.erl:8: Warning: variable 'X' is unused
foo.erl:8: Warning: variable 'X' shadowed in 'fun'
That warning about 'X' being shadowed?
LOVE IT LOVE IT LOVE IT!
More information about the erlang-questions
mailing list