On Mon, Jul 01, 2002 at 02:52:06PM -0500, Me wrote: > Current p6 rx syntax aiui regarding embedded code: > > / > #1 do (may include an explicit fail): > { code } > > #2 do with implicit 'or fail' > <( code )> > > #3 interp lit: > $( { code } ) > > #4 interp as rx: > <{ code }> > / > > This feels cryptic. Do we need abbreviated syntax for > all these cases? If we do, is there a better syntax for > this stuff?
They're not entirely cryptic, it's just a new set of mnemonics. I don't think anyone would argue against C< {...} > as the most recognizable flag for "code" possible, which makes it the best choice for the most ordinary case. C<< <...> >> are assertions, so it makes sense that #2 and #4 use that syntax. Their contents will either match (for their own definition of "match") or not, and the results are just as if you'd used a simple assertion like C<< <alpha> >> in the same position. The parens in #3, C<< <( code )> >>, make sense if you think of C< ( condition ) > as a kind of shorthand for C< if ( condition ) >. The combination of "assert" and "condition" is a nice symbology for: { fail unless ( condition ); } The curly-braces in #4 make sense because it's executing code to get a return value (which is more what we would expect from a block than just getting a "truth" value). Think of it as analogous to C<< <$pat> >>, only the value of $pat is returned instead of pre-existing within a variable. And, C< $( code ) > fits nicely with the general (non-regex) syntax for interpolating a scalar expression. Allison