> OK, I have a question. > > On page 3 you say: > > > Because the Perl 6 "diamond" operator can take an arbitrary expression > > as its argument, it's possible to set a filehandle to read an entire > > file and do the actual reading, all in a single statement: > > > > my $rest = <$data.{fh}.irs(undef)> > > If the diamond operator can take an arbitrary expression, how is this > properly parsed? > > my $line = < $some_counter_or_something > 1000 ?? $file1 :: $file2 >;
"Syntax error near 1000" > Wouldn't the '>' comparison operator screw it up? Or is it an arbitrary > expression except that you can't use the greater-than operator? Or is the > parser that smart? It *might* be that smart, but I make no promises. In practice, the diamond can take an arbitrary expression provided that expression is valid (same as the rest of Perl). To do what you want, you'd probably write: my $line = < ($some_counter_or_something > 1000) ?? $file1 :: $file2 >; or my $line = < do{$some_counter_or_something > 1000) ?? $file1 :: $file2} >; or: my $line = < $some_counter_or_something <= 1000) ?? $file2 :: $file1 >; etc. Damian