Re: redraft (v2) for RFC 348 Regex assertions in plain Perl code
[email protected] (Hugo) Sun, 01 Oct 2000 18:43:27 +0100
| Newsgroups | perl.perl6.language.regex |
|---|---|
| Message-ID | <[email protected]> |
In <[email protected]>, Bart Lateur writes: :Likely the most justifiable to want to be able to execute Perl code in a >> reason :This makes the implementation very tricky. I :wouldn't be surprised if precisely this feature is the main reason why :the current implementation is so notoriously unstable. I'm not aware of any instability caused by this. The instability is caused by various other factors, discussed at length on p5p. :The fact that the embedded code is called 3 times, not more, surely :suprised me. It probably will surprise many people. Apparently, it is :only executed once for every lowercase letter, not just for any :character. : :This inpredictability is yet another reason to discourage incrementally :modify global data structures. I think this is precisely why the non-assertion form encourages use of local() - in general, the local() constructs will have executed a predictable number of times _that have not been unwound_ by the time a successful match is achieved. I don't think this observation (of mine) is particularly relevant to the proposal, however. :=head2 /(?(condition)yes-pattern|no-pattern)/ The simplest form of this is (?(1)yes|no). This is rather harder to emulate with other mechanisms without running to eval. OTTOMH it is equivalent to (??{ defined($1) ? 'yes' : 'no' }). Hugo