Re: New EEP draft: Pinning operator ^ in patterns
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <20210122121741.1716b270@aesop> |
On Wed, 20 Jan 2021 20:59:49 +0100 Richard Carlsson <[email protected]> wrote: > Den ons 20 jan. 2021 kl 17:27 skrev Raimo Niskanen < > [email protected]>: > > > 1: foo(Y) -> > > 2: F = fun (Y) -> > > 3: FF = fun (Y) -> > > 4: ^Y = Y - 1 > > 5: end, > > 6: FF(Y + 1) > > 7: end, > > 8: F(Y + 1). > > Can I match against the Y bound on line 1 from within FF/1? > > > > No, that's buried by two levels of shadowing. In the head of F on line 2 > you could refer to the Y on line 1, but that's it. Even in the body of F, > the outer Y would not be available. Unless next year someone wants to solve a problem by C10 in http://erlang.org/pipermail/erlang-questions/2021-January/100399.html > Bruijn notation, I think such uses would lead to madness. I have seen pigs fly ... they say. For what reason(s) not put it like this? > > 1: foo(Y) -> > > 2: F = fun (B) -> > > 3: FF = fun (C) -> > > 4: B = Y - 1 > > 5: end, > > 6: FF(B + 1) > > 7: end, > > 8: F(Y + 1). Y is it useful to have all those Ys in all examples? I can imagine only two places: Highlighting the making visible of an invisible difference: `{^Y, Y} = ...` And a section with examples proving that shadowing is not affected. ~Michael -- “Even after a thousand explanations a fool is no wiser, whereas someone intelligent requires only one fourth of these.” – from the Mahābhārata (महाभारत)