On Sat, Apr 05, 2008 at 01:41:02PM -0500, John M. Dlugosz wrote: > Larry Wall larry-at-wall.org |Perl 6| wrote: >> On Wed, Apr 02, 2008 at 06:08:55PM -0700, Jon Lang wrote: >> : In "Question on your last change to S02", Larry Wall wrote: >> : > (By the way, you'll note the utility of being able to talk about a >> : > postfix by saying .[], which is one of the reasons we allow the optional >> : > dot there. :) >> : : Can I take this as an indication that the rules for postcircumfix >> : operators are an extension of the rules for postfix operators? >> >> Yes, postcircumfixes are just strange postfixes, syntactically >> speaking. Semantically they may do strange things such as behave >> more like macros than operators, of course. Certainly .() is highly >> magical that way, and maybe subscripts too. >> >> Larry >> > Magical how?
I only mean that you can't simply rewrite $foo.($bar) as $foo.postcircumfix:<( )>.($bar) and think you've gotten anywhere, since you'd then have to rewrite it again: $foo.postcircumfix:<( )>.postcircumfix:<( )>.($bar) $foo.postcircumfix:<( )>.postcircumfix:<( )>.postcircumfix:<( )>.($bar) ... Something has to recognize it as a special form. > I take it that the macro-like behavior is in how the circumscribed text is > parsed, and once that has been collected, it behaves just like a function > call to a function named postcircumfix:<( )> etc.? > > And if I create a function named postcircumfix:<[ ]> (or one of the > others), I get the _same_ magic as normally applied to subscripts? If it's > a matter of defining the argument as @@ (for subscripts) or Capture (for > function-call syntax), that's not magic. Well, it's possible the subscript itself isn't the magical part there. At minimum, the semilist rule probably needs to recognize @@ and ** at the top level (or @@ and ** need to recognize that they're at the top level of a context that wants them to interpolate multiple dimensions rather than just one). It's also possible that even this amount of syntactic magic is evil, but I'd like [1;**;3] to know it has an arbitrary number of dimensions, while [1;$two;3] should know that it has exactly three dimensions even if $two happens to contain ** or @@. It's also possible I'm just nuts, and slice context should be a purely run-time activity. Larry