On Fri, Jul 01, 2005 at 09:43:02AM -0700, Larry Wall wrote: > On Fri, Jul 01, 2005 at 08:38:01AM +0100, Nicholas Clark wrote: > : Does this mean that you're using the same recursive approach that the perl 5 > : regular expression engine uses? (Not that I understand much of the perl 5 > : engine, except that uses recursion to maintain parts of state) > > No, Perl 5 has to use recursion to emulate co-routines. Parrot has > real co-routines/continuations, so PGE can actually return at the end > of a submatch where P5 has to recurse, since P5 can only represent > failure by a return. So I think PGE's recursion is much more faithful > to the shape of the problem.
Aha. I didn't realise that co-routines were the need for recursion in perl 5's regexp engine. Does this mean that to remove recursion from perl 5, instead of re-writing the engine to be iterative, it might be easier to emulate co-routines using setjmp/longjmp, retaining almost all of the existing code? http://www.chiark.greenend.org.uk/~sgtatham/coroutines.html Nicholas Clark