Aaron Sherman wrote:
>     rule { <term> { /@operators/.commit(1) or fail } <term> }
>     
> The hypothetical commit() method being one that would take a number and

That would only be useful if the outer rule can backtrack into the
inner /@operators/ rule. Can it?

I agree with you that a commit method would be useful -- especially when
used on $self. I'd probably write your example as:

  rule { <term> { m/@operators { $self.commit(1) }/ or fail } <term> }

which is of course just a complicated

  rule { <term> { m/@operators :/ or fail } <term> }

BTW, why isn't fail a method? Then a rule could pass itself to a sub-rule
and allow the sub-rule to fail it's parent, but not the entire match. Isn't
failing just invoking the last continuation on the backtrack stack?

- Ken

Reply via email to