[erlang-questions] Inconsistent shadowing of variables in a fun
Mon Jan 30 01:17:32 CET 2017
The shadowing warning is there because it is only there and list
comprehensions where variable in patterns are shadowed. No, it isn't
consistent but it follows how other functional languages do it, IIRC. The
problems with an evolving language.
On 30 January 2017 at 00:17, Richard A. O'Keefe <> wrote:
> On 30/01/17 11:06 AM, Robert Virding wrote:
>> When defining a fun the shadowing of variables occurring in arguments is
>> 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).
> 3> foo:b(0).
> 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!
> erlang-questions mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the erlang-questions