Re: [pcre-dev] (*THEN) works differently in Perl

Top Page
Delete this message
Author: Zoltán Herczeg
Date:  
To: pcre-dev@exim.org
CC: ND
Subject: Re: [pcre-dev] (*THEN) works differently in Perl
> Note that if this operator is used and NOT inside of an alternation
> then it acts exactly like the "(*PRUNE)" operator.
> But it doesn't.


Perhaps the misunderstanding comes from the fact that we are talking about the pattern and they talk about the matching process. So (*THEN) simply starts a backtrack, and when an alternation is encountered, it switches to the next alternative. But this happens normally as well, so what is the exact purpose of this verb then?

This is also very confusing (especially if you read the documentation):
/(a(a|b)c(*THEN)d|e)/

It says:
Its name comes from the observation that this operation combined with the alternation operator ("|" ) can be used to create what is essentially a pattern-based if/then/else block:

( COND (*THEN) FOO | COND2 (*THEN) BAR | COND3 (*THEN) BAZ )

But if your cond has an alternation, it will do something else.

I think they simply introduced some random verb which is easy to implement for them, but totally confusing for a user. Imagine if (*THEN) backtracks into an atomic block, or a recursion. Btw this type of (*THEN) is impossible to implement in JIT, because static analysis of its effect is not always possible.

Regards,
Zoltan