Larry Wall larry-at-wall.org |Perl 6| wrote:
At compile time the subscript parser really only knows how
many dimensions are referred to by how many semicolons there
are. A subscript that is explicitly cast to @@ is known to be
multidimensional, and interpolates the returned List of Capture into
Larry Wall larry-at-wall.org |Perl 6| wrote:
Now, you'll ask how *-2 works. If you do math on a Whatever object,
it just remembers that offset until the Whatever is given a meaning,
which, in this case, is delayed until the subscripting operator
decides what the size of the next dimension is. A
Hmm, both of you are kinda going off on a tangent here. The meaning of
the Whatever represented by * is neither something that gets magically
interpreted before postcircumfix:<[ ]>, nor is it a compile-time
rewrite. Context is supplied by binding in Perl 6, and the binding
happens within .[]. It
TSa Thomas.Sandlass-at-barco.com |Perl 6| wrote:
Now my question: could slice context be a runtime feature that acts
before the dispatch to &postcircumfix:<[ ]> by retrieving the shape
of the @array and handing it over to &foo as context, capture the
shape of the slice returned and hand over the
HaloO,
John M. Dlugosz wrote:
So a function can only supply values for one dimension? Given
@array[foo;bar]
each function is called in list context and returns a list for one of the
dimensions.
But what if you wanted a function to replace the literal subscript in:
@array[1,2;1;3]
@a
The context in which a subscript is evaluated is no longer controlled
by the sigil either. Subscripts are always evaluated in list context.
+(More specifically, they are evaluated in a variant of list context
+known as I context, which preserves dimensional information
+so that you can do multi-