Do all Perl 6 quoting constructs have term precedence?

Viewed 270

The < > has term precedence. Here's the example from the docs:

say <a b c>[1];

I figured the same precedence would apply to all of the quoting operators. This works:

my $string = '5+8i';
my $number = <<$string>>;
say $number;

This interpolates $string and creates allomorphes (in this case a ComplexStr):

(5+8i)

But, if I try to index it like the example from the docs, it doesn't compile:

my $string = '5+8i';
my $number = <<$string>>[0];
say $number;

I'm not quite sure what Perl 6 thinks is happening here. Perhaps it's thinking it's a hyperoperator:

===SORRY!=== Error while compiling ...
Cannot use variable $number in declaration to initialize itself
at /Users/brian/Desktop/scratch.pl:6
------>     say $⏏number;
    expecting any of:
        statement end
        statement modifier
        statement modifier loop
    term

I can skip the variable:

my $string = '5+8i';
say <<$string>>[0];

But that's a different error that can't find the closing quotes:

===SORRY!=== Error while compiling ...
Unable to parse expression in shell-quote words; couldn't find final '>>'
at /Users/brian/Desktop/scratch.pl:8
------> <BOL>⏏<EOL>
    expecting any of:
        statement end
        statement modifier
        statement modifier loop
2 Answers
Related