为什么新的运算符定义不保留在 Perl 6 REPL 中?
Why don't new operator definitions persist in the Perl 6 REPL?
我在尝试在 Perl 6 REPL 上定义运算符时遇到问题,并注意到它们确实有效,但仅当在定义它们的同一行上使用时。为什么会这样?
> sub postfix:<!>(Int $x where { $x >= 0 }) { [*] 1..$x }; 6!;
720
> 6!;
===SORRY!=== Error while compiling:
Negation metaoperator not followed by valid infix
------> 6!⏏;
expecting any of:
infix
infix stopper
这是一个错误。
有关详细信息,请参阅错误报告 Perl6 REPL forgets the definition of ... and REPL issue defining new operator...。
我在尝试在 Perl 6 REPL 上定义运算符时遇到问题,并注意到它们确实有效,但仅当在定义它们的同一行上使用时。为什么会这样?
> sub postfix:<!>(Int $x where { $x >= 0 }) { [*] 1..$x }; 6!;
720
> 6!;
===SORRY!=== Error while compiling:
Negation metaoperator not followed by valid infix
------> 6!⏏;
expecting any of:
infix
infix stopper
这是一个错误。
有关详细信息,请参阅错误报告 Perl6 REPL forgets the definition of ... and REPL issue defining new operator...。