On Thu, 2002-08-29 at 10:28, Ken Fox wrote:
> 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?

Of course not. In the same way that 

    rule foo { b }
    rule bar { a <foo>+ b }
    "abb" =~ /<bar>/

would not. You backtrack OVER it, and that's when your commit (of
whatever degree) would come into play.

> 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> }

There's no way that can affect anything, as ":" doesn't affect calling
rules, e.g.:

        rule foo { b : }
        rule bar { a <foo>+ b }
        "abb" =~ /<bar>/

will match, because the foo rule never needs to backtrack. If foo had
used C<< <commit> >>, then you'd fail, but that's a horse of a different
animal.

The goal was to dynamically cause backtracking over inline code to fail.


Reply via email to