Larry Wall |Perl 6| wrote:
I only mean that you can't simply rewrite



    $foo.postcircumfix:<( )>.($bar)

and think you've gotten anywhere, since you'd then have to rewrite it

    $foo.postcircumfix:<( )>.postcircumfix:<( )>.($bar)
    $foo.postcircumfix:<( )>.postcircumfix:<( )>.postcircumfix:<( )>.($bar)

Something has to recognize it as a special form.

You lost me. Why does it apply operator(), er, postcircumfix:<( )> multiple times on successive return results?

Well, it's possible the subscript itself isn't the magical part there.
At minimum, the semilist rule probably needs to recognize @@ and ** at the
top level (or @@ and ** need to recognize that they're at the top
level of a context that wants them to interpolate multiple dimensions
rather than just one).

It's also possible that even this amount of syntactic magic is evil,
but I'd like [1;**;3] to know it has an arbitrary number of dimensions,
while [1;$two;3] should know that it has exactly three dimensions even
if $two happens to contain ** or @@.
Your previous description of handing * in array subscripting explained that it was done at run-time. From that earlier discussion, nothing in the parsing of the text between the brackets interacts with the declared properties of the array.

So, in slice context 1;$two;3 will contain 3 lists. Even without slice context, a scalar variable like $two never interpolates but adds a single value to the list (so it is writ). So when postcircumfix:<[ ]> looks at its argument at runtime, it would see [ [1], [**], [3] ], assuming I'm writing that correctly. What $two happens to contain should not matter, or you've lot a lot more revising to do.

It's also possible I'm just nuts, and slice context should be a purely
run-time activity.

That doesn't mean that the standard postcircumfix<[ ]> should be defined to handle what it sees as ** inside one of its arguments. Perhaps it should use the cardinality of its argument (a list of lists) as an indication of what it should do, and then if it finds something in one of those sublists that is not a list of indexes, it is an error.

That means if you wanted to compose the number of dimensions at run-time, you would have to explicitly use a construct that did the proper amount of flattening, e.g. [1; @@ $two; 3].


Reply via email to