Using Perl6 Section 4.6 #18

dha opened this Issue Aug 31, 2010 · 2 comments


None yet

2 participants

dha commented Aug 31, 2010

First, the use of all() is unexplained. Some of us are familiar with junctions from Damian's Quantum::Superpositions talk, but the docs probably shouldn't require that you have been at a Perl Conference ten years ago to make sense of it. :-) Also, if you play with the code in this section, you find that what gets returned is a junction, which really won't make sense to the uninitiated.

Also, the first paragraph refers to "ordinary slicing access", but what does that refer to? Perl5 style slices? Other than the reference to the "Zen slice", there's been no reference to slicing in this document. Is the first section of the first example supposed to be "ordinary slicing", followed by the second section which is "signature binding"? Since neither does the unpacking in the actual signature of the subroutine, I find that unclear.

Next, there is the line 10 of the first example: "my :($first, *@rest) := (|@a)". A couple of issues with this... What's that colon doing after the my (I suspect this one is a typo)? What does the := operator do? Why are we creating a capture on the right hand side of the expression?

Util commented Sep 1, 2010

Re: all/junction - I agree. To resolve, the code could be changed to:
return not ?@rest.grep( { $first < $_ } );
If we keep using all(), we should at least cast to Bool so that we don't return a junction:
return ?( $first >= all(@rest) );

Util commented Sep 1, 2010

re: Line 10. I am looking at this, but my understanding is clouded by Rakudo's incomplete implementation of list binding. Thoughts on your questions:

  1. I think the colon is a typo. Another typo is that the line is missing its closing semi-colon. 2. The := operator does "binding" (as opposed to = doing "assignment"); it makes the LHS point to the the same container as the right-hand-side, instead of copying the value. In Perl5, see Data::Alias. 3.Because we need the capture to generate the references that we will bind to, maybe? S06."Flattening argument lists" is the closest explanation I have found, but I am still uncertain that our syntax is correct.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment