< >
具有期限優先權。這裏的example from the docs:是否所有Perl 6引用構造都具有期限優先權?
say <a b c>[1];
我想通了相同的優先級將適用於所有的報價運營商。這工作:
my $string = '5+8i';
my $number = <<$string>>;
say $number;
這插值$string
並創建allomorphes(在這種情況下ComplexStr):
(5+8i)
但是,如果我嘗試爲它像是從文檔的例子,它不編譯:
my $string = '5+8i';
my $number = <<$string>>[0];
say $number;
我不太清楚Perl 6認爲這裏發生了什麼。也許是認爲它是一個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
我可以跳過變量:
my $string = '5+8i';
say <<$string>>[0];
但是,這是一個不同的錯誤不能找到收盤行情:
===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
另一個數據點:'<<"$string">> [0]'按預期工作 – Christoph
確實。 '''只是另一種防止解析器進入'>>。'死衚衕的方法。 –