closure on function argument

Zoltan Lajos Kis kiszl@REDACTED
Sat May 1 20:38:10 CEST 2010


Hi,

If I have /F = fun(Y) -> fun(Y) -> ok end end/, and /G = F('z')/, I 
would expect /G/ to be /fun('z') -> ok end/.
Apparently, it is /fun(Y) -> ok end/, as calling it with any argument 
returns /ok/ and never causes a function clause exception.
I guess that the inner /Y/ being an argument "automatically" shadows the 
outer one.

A workaround I found is using guards: /F = fun(Y) -> fun(X) when X == Y 
-> ok end end/.
The question is: is there a way to create a direct binding between the 
inner and outer /Y/'s in the original example?

Thank you,
Zoltan.




More information about the erlang-questions mailing list