Raku / doc

🦋 Raku documentation
https://docs.raku.org/
Artistic License 2.0
286 stars 293 forks source link

Docs on Whatever curry could be clearer / don't cover everything #2017

Open zoffixznet opened 6 years ago

zoffixznet commented 6 years ago

Glancing at the intro section on https://docs.perl6.org/type/Whatever I notice a couple of problems.

  1. Roughly the second half of the section is probably not clear enough for the average reader. The section even introduces the term "stored *" only to backtrack on it and try to explain that curry already happened before it.
  2. The information doesn't give all the details when curry happens. Especially when it comes to chained Whatever stars, such as * ≥ * ≥ *, *.uc ~~ *, *.uc xx *.abs etc. In code form (and should already be fairly covered by spec) the list of what decisions are made is encoded here. I think this full information can replace the current second portion of the description.
  3. The section should probably mention that HyperWhatever exists, considering how close the two constructs are.

Update with a couple more comments on the subject: http://colabti.org/irclogger/irclogger_log/perl6?date=2018-09-26


00:54 | Zoffix | vrurg: it's a hardcoded list of things: https://github.com/rakudo/rakudo/blob/da646aa2ee6e3064bdef905f5c0b54b4bd0b2797/src/Perl6/Actions.nqp#L9634-L9665 there's a yet-to-be-fixed docs Issues on the topic D#2017
00:54 | synopsebot | D#2017 [open] : https://github.com/perl6/doc/issues/2017 [docs] Docs on Whatever curry could be clearer / don't cover everything
00:58 | Zoffix | `*` is "Whatever" in those comments, and an already-closurised thing is a "WhateverCode". So, for example in `*.uc.lc` => `*` Whatever => the `.uc` is a `callmethod` op, and so we make a WhateverCode => we now get to `.lc`, since `callmethod` op is level `3` in that list, we continue closing over it and make `{.uc.lc}`-equivalent closure (without the new scope). But `&infix:<~~>` is level 1, so with `*.all ~~
00:58 | Zoffix | Blah` => `.all` is callmethod op, we curry it => we get to `~~` op with WhateverCode in hands, and since `~~` is level 1, we don't curry anymore. But with `* ~~ Blah` we have a Whatever, not WhateverCode, on LHS, so we do curry the level 1 `~~` op
JJ commented 5 years ago

I'm trying to solve this issue, and the main problem I'm finding is that I'm not sure currying is used properly here. In general, it translates the evaluation of a function with multiple arguments to the evaluation of a sequence of functions with single arguments. That's the general idea. In this case, I can't even see where are the placeholders for "functions" and "arguments". Whatever is a class, it it's used as a term it might make the whole construct a WhateverCode; WhateverCode is actually a functor. Functors are effectively curried when they receive arguments. So I guess we're talking about two different processes here: when and how Whatever (or HyperWhatever) are functorized (not curried, they are not functions) and when WhateverCode is curried. Am I too far off mark?

Scimon commented 5 years ago

If they were currying I'd expect this to work : my &f = * + *;my &g = &f(2);say &g(2)

JJ commented 5 years ago

That's the other part of the issue, the "stored whatever". But that's right, it's not clear where the concept of currying fits here.