On Tue, Dec 30, 2008 at 09:52:10AM -0800, Patrick R. Michaud via RT wrote:
: On Tue Dec 30 01:47:47 2008, masak wrote:
: > Just wondering whether the following syntax, currently accepted by
: > Rakudo r34628, is legal Perl 6:
: >
: > $ perl6 -e 'say ("a".."c").list[0..**-1]'
: > abc
:
:
: As of r34652, this now produces an empty list (which is what I would
: expect).
:
: $ perl6 -e 'say ("a".."c").list[0..**-1]'
:
: $
:
: Rakudo is parsing **-1 as "whatever times -1", which means the range is
: being computed as 0..-3, which produces an empty slice.
According to S02 and S09, term:<**> is supposed to be a dwimmy
HyperWhatever, so the above should parse ** as a single term, and it
should end up meaning something like:
-> *...@dims { map { 0 .. *-1 }, @dims )
which, since there's only one dimension in the subscript, should
degenerate to
0..*-1
which is the same as
^*
or even
*
for that matter.
Which means we probably need to figure out how to write the sort of
partial binding that a C<for> loop does, since subscript now appears
to want the same sort of partial binding that processes the next
N dimensions of the subscript, whenever it finds a Code subscript.
And it would be much better to let the binding figure out and report
where it gave up than to second-guess by inspection of arities and
such. The implementation of C<for> should just do that repeatedly
to whatever remains of its list. Maybe it's just a form of binding
that removes elements from a list as it binds them.
Well, maybe we almost have the notation already.
($some, $sig, |$remaining) := |$remaining
except that we need to be able to interpolate :($some, $sig) into the
left side somehow with the |$remaining at the same capture level.
(We have subsig matching currently, but only applied to the next
argument.)
Or looking at the other way, given a signature $somesig, we need
some way of appending a |$remaining on the end to slurp up whatever
remains of the capture when the binding stops.
Well, my brain feels like it's in sideways today, so I'd better stop
before I say something profound but wrong...
Larry