develooper Front page | perl.perl5.porters | Postings from September 2011

Re: [perl #92898] (*THEN) broken inside condition subpattern

Thread Previous | Thread Next
From:
Aristotle Pagaltzis
Date:
September 21, 2011 04:42
Subject:
Re: [perl #92898] (*THEN) broken inside condition subpattern
Message ID:
20110921114238.GA28796@klangraum.plasmasturm.org
* Philip Hazel <ph10@hermes.cam.ac.uk> [2011-09-21 11:20]:
> I've been thinking about this some more. My naive understanding
> of *THEN is basically this: it is effectively just another way
> of doing what (?>...) does, but with possibly simpler syntax
> and the added feature of *THEN:NAME. The emphasis on
> alternation is really a red herring. Thus, if you have
>
>    A (*THEN) B
>
> (where A and B are complex patterns) the matching engine,
> having passed (*THEN) and subsequently failed in B, no longer
> backtracks into A. This would be the same:
>
>    (?>A)B

That is how I understand it as well.

In which case the emphasis on alternation is not entirely a red
herring, as the question it tries to address is that both (*THEN)
and (*PRUNE) could be considered the closing paren of an atomic
group which differ in where the opening paren is inferred to be
(start of pattern vs start of group) – which makes the most
practical difference inside alternations, where (*PRUNE) causes
a very different effect from (*THEN). In most other cases the
difference in matching is very much subtler.

It occurs to me that “THEN” is really the wrong thing to call
this predicate. It should be maybe “ASLONGAS”. That is

    A(*THEN)B

translates to something like “match A as long as B also matches
from that point on”.

Regards,
-- 
Aristotle Pagaltzis // <http://plasmasturm.org/>

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About