On Thu, Jun 02, 2005 at 12:52:36AM -0400, Jeff 'japhy' Pinyan wrote:
> Further woes, arguments, questions:
>
> In regards to <@array>, A5 says "A leading @ matches like a bare array..."
> but this is an over-generalization. A leading '@' merely indicates the
> rule is found in an array. <@array[3]> would be the same as
> <$fourth_element_of_array>, assuming those two values are identical.
I'll leave this to the A05 authors to decide. :-) S05 doesn't
present any examples of subscripted rules or hashes, so perhaps
that particular syntax was reconsidered (i.e., I think one could
do <{ @array[3] }>).
> Next, about <before RULE> and <after RULE>. What is the justification for
> that syntax? There is no other example of a <-sequence with whitespace,
> at least that I can see. It would appear "RULE" is an argument of sorts
> to the 'before' and 'after' rules, but how do they access that argument?
> How do I write a rule that takes an argument?
According to A05, rules take arguments much the same way that
subs do. (In fact, it's *very* useful to think of rules as subs or
methods.) So, one can do:
rule myrule ($x) { \w+ $x }
and $x is scoped something like a subroutine parameter would be.
A05 also mentions several mechanisms for passing parameters to
a rule:
<myrule pattern> # same as calling myrule(/pattern/)
<myrule: text> # same as calling myrule(q<text>)
<myrule(expr)> # same as calling myrule(expr)
Of course, there are other "implicit" parameters that are given
to a rule -- the target string to be matched and an initial
starting position. But I think some of those details are still
being worked out.
Pm