在 Oct 3, 2006 10:22 PM 時,Wim Vanderbauwhede 寫到:

say (-> $n { -> $f { $f($n,$f) }.( -> $n, $f { $n<2 ?? 1 !! $n*$f ($n-1,$f)
}) }).(5);
say "OK";
#say (-> $n { -> $f { $f($n,$f) }.( -> $n, $f { $n<2 ?? 1 !! $n*$f ($n-1,$f)
}) }).(5);
say "OK";

It's extremely subtle -- $n<2 should never have parsed in the first place, because it's always a hash dereference (as in $n<2>); put a whitespace before the < sign to get the infix comparison
operator you're looking for.

See L<S03/Changes to Perl 5 operators/"Note that Perl 6 is making a consistent three-way distinction">
for more details on this distinction.

Pugs should have never admitted the first $n<2 case (by scanning outward to a matching > and failing+backtracking), and should instead say someting like "write $n < 2 instead". Can you commit a test to make sure that "1<2" is a parse failure, perhaps as t/syntax/ parsing/lt.t?

A commit bit is on your way. Remember to add yourself to AUTHORS first. :-)

Thanks!
Audrey

Reply via email to