Skip to content

In List.rakudoc, clarify wording around the subroutine version of rotor#4762

Merged
schultzdavid merged 4 commits intomainfrom
schultzdavid-patch-6
Feb 8, 2026
Merged

In List.rakudoc, clarify wording around the subroutine version of rotor#4762
schultzdavid merged 4 commits intomainfrom
schultzdavid-patch-6

Conversation

@schultzdavid
Copy link
Collaborator

@schultzdavid schultzdavid commented Feb 2, 2026

https://docs.raku.org/type/List#routine_rotor

Changes:

  • Rearrange lines to make clearer what was introduced with v6.e.

  • Update signatures: what was \source is now \thing (v6.e on MoarVM version 2025.10).

  • One 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 — see example below), so that ** is more appropriate than *. (Of course, technically, it's neither, as the comment actual sig is **@cycle-and-thing but only due to Rakudo limitation explains — 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:

> rotor( (7,8), 1, 2, 'a' .. 'h')  # the first list just counts as 2
((a b) (c) (d e) (f g) (h))

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>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Collaborator Author

@schultzdavid schultzdavid Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So for teaching purposes, we should consider this the correct signature, even though Rakudo itself can’t compile it?

Copy link
Collaborator Author

@schultzdavid schultzdavid Feb 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@schultzdavid schultzdavid requested a review from coke February 3, 2026 14:12
@schultzdavid schultzdavid merged commit 5a746e5 into main Feb 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants