In List.rakudoc, clarify wording around the subroutine version of rotor#4762
In List.rakudoc, clarify wording around the subroutine version of rotor#4762schultzdavid merged 4 commits intomainfrom
Conversation
Rearrange lines to make clearer what was introduced with v6.e. Update signatures: what was `\source` is now `\thing`. Substantial change: In the second signature, write `**@cycle` instead of `*@cycle`, because list arguments don't get flattened here (rather, each list counts as one Int), so that `**` is more appropriate than `*`.
| compiler 2022.02+). | ||
| =for code | ||
| multi rotor(Int:D $batch, \thing, Bool() :$partial --> Seq:D) | ||
| =for code :skip-test<actual sig is **@cycle-and-thing but only due to Rakudo limitation> |
There was a problem hiding this comment.
If this signature compiles, the skip isn’t needed. Maybe just a rakudoc comment (hidden from the user) explaining why it’s not the same in the rakudo source.
There was a problem hiding this comment.
The skip and the comment were already introduced with @lizmat's edit. I've now tested it in the REPL, where this (the second) signature indeed doesn't compile, since there's a slurpy at the very beginning of the signature and then the required parameter \thing coming after it:
Cannot put required parameter thing after variadic parameters
There was a problem hiding this comment.
So for teaching purposes, we should consider this the correct signature, even though Rakudo itself can’t compile it?
There was a problem hiding this comment.
Good question about the didactics.
For understanding the routine rotor, I think this "as-if" signature really is the right choice. For example, the method signature at the very top reads
method rotor(*@cycle, Bool() :$partial --> Seq:D)
so that after its discussion, understanding the routine becomes very straightforward through the (technically wrong) signature
multi rotor(*@cycle, \source, Bool() :$partial --> Seq:D).
However, some visible note stating that this is just for teaching and technically illegal would certainly be good. I'll think of something. (Also, I might still have to adapt * to ** in the method signature at the top, or rather to + it seems.)
…ure. The method `rotor` has `+@cycle` and not `*@cycle` for its signature (according to introspection and its actual behavior).
The problem would be the same if the parameter were optional.
https://docs.raku.org/type/List#routine_rotor
Changes:
Rearrange lines to make clearer what was introduced with v6.e.
Update signatures: what was
\sourceis now\thing(v6.e on MoarVM version 2025.10).One substantial change: In the second signature, write
**@cycleinstead of*@cycle, because list arguments don't get flattened here (rather, each list counts as one Int — see example below), so that**is more appropriate than*. (Of course, technically, it's neither, as the commentactual sig is **@cycle-and-thing but only due to Rakudo limitationexplains — because actual slurpies can only come at the end — but even so the behavior is much more like**than like*.)Example for the last point: