Re: New EEP draft: Pinning operator ^ in patterns
Richard Carlsson <[email protected]>
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CANKG3zme5qxYc=p9itCen49LtvcY_CBBaB3Q1dEz8DQREXSOjw@mail.gmail.com> |
Den ons 20 jan. 2021 kl 15:42 skrev Raimo Niskanen < [email protected]>: > I have vague feeling that this has been asked, > but since I can not find it: > > How is nested fun()s handled? > > foo(Y) -> > F = fun (X) -> > Y = X + ^Y, > FF = fun (Z) -> > Z + ^Y > end, > FF(Y) > end, > F(Y). > > Does the innermost Z + ^Y access the outermost Y from foo(Y), or the Y > bound in F/1 i.e Y = X + ^Y? > > Is there a way to choose which of the outer Y:s to refer to from within > FF/1? > No, the ^X notation is only allowed in patterns, it is an error to use it elsewhere. It is only needed in patterns since they form the boundary between existing bindings and new bindings. While I could imagine ways to interpret ^X technically in expressions as well, like some kind of de Bruijn notation, I think such uses would lead to madness. /Richard