On Wed, Mar 02, 2005 at 01:24:59PM -0600, Rod Adams wrote:
: Thanks for pointing that out, Patrick. I'm impressed with how you've 
: assimilated all the S's & A's. (And yes, I love that the guy in charge 
: of implementing the language has that ability.)

Yes, Patrick is a jewel.  We'll probably wear some new facets on him though.

: And now some questions to hammer out some details on passing args to 
: subrules:
: 
: What if you wish to pass two args, the first a string, the second a rule?
: Are you then forced to use <name(expr, expr)> syntax?

Yes, or pass a string and parse it yourself.

: Does <name: text1 text2> get handled as <name(q<text1 text2>)> or as 
: <name(q<text1>, q<text2>)>, in which case it's really qw//?

The former.  It's a single string, which you can parse however you like.
Though I suppose we could extend the colon to a colon modifier:

    <name:w text1 text2>

That's getting a little weird though, considering that in most other cases
such modifiers are outside the delimiters.  Here's a really weird one:

    <name:here END>

I'm more inclined to say that anything beyond a bare string has to use
function notation.  I'm still not entirely sure we should even have a
string notation.  Its utility/clutter ratio is pretty low.

: If I declare my rule as:
: 
:  rule MyRule (Str $text) { ... }
: 
: Will the P6RE be smart enough to pass:
: 
:  m:{<MyRule /thisdir/>}
: 
: As a string, not the rule that it looks like?

Probably not, given the late-binding issues and the desire to treat
patterns as first-class language.  That's why we're differentiating
the call syntax without reference to the called signature.  If you
want delayed compilation of the pattern, you can get it by passing
a string.  But then any parentheses in it don't count as parens in
the outer rule.  With <before ([A-Z]+)> we can treat the lookahead
parens as an ordinary capture because the parens are parsed at the
same time the outer rule is parsed.

: If I define a named rule, how do I get a reference to it from outside a 
: rule?
: A05 leads me to think that
: 
:  my $rx := Rule.MyRule;
: 
: will work, assuming Rule is the default gramme. I would also suspect 
: that one could reverse this.
: 
:  my $rx = rule { ... };
:  Rule.MyRule := $rx;
: 
: Thus defining a new rule dynamically.

You have to use &Rule::MyRule to refer to the method by name.  Rule.MyRule
would invoke the MyRule method as a class method in the Rule class, since
method calls do not require parens if there are no arguments.

Larry

Reply via email to