With patch Change #29430 the regex engine should now be sufficiently abstracted that it is reasonably feasable to write a plugin to use a different regex engine in perl. The documentation for most of the interface is contained in the perlreguts module although one needs to understand the flags in the regexp.h in order to make it work.
The basic idea is that the existing perl engine and data structures have been ripped in half. The structures which the perl core must interact are now well defined and the parts that are "private" to a given regex engine implementation are now isolated from the core.
A big issue with Perl 5.8 and earlier Perls regex engine pluggability interface was that it was intended mostly for swapping in a DEBUG build of the real engine, with the expectation that any engine in use could cope with the data structures generated by any other engine. Additionally some of the management routines for regexps were harded coded into the core, with the expectation that the core routine could handle any engines data. All of these design issues meant that basically you couldnt plug an arbitrary engine into perl. You would have to apply core patches to do even the meanest implementation.
In the new scheme what Perl needs to know about a pattern, is defined by the struct regexp
. What Perl needs to know about a regex engine is defined by the struct regexp_engine
. All a plug in needs to do is create a regexp_engine
that contains the appropriate callbacks and populate %^H appropriatly when the module is use()d. Perl will then use the compiler routine specified by the engine to create a regexp
struct which it will then use as though it was its own. The regexp
structure contains a pointer to the regexp_engine
structure which created it, so the regexp is completely encapsulated. You can compile a regexp using one engine and pass it through to a routine expecting a normal regexp and everything would work out.
So now all we need to do is get some intrepid hacker to actually put all this to good use and write a plug in for another engine.
And you know what?
The first person that publishes a proper regexp engine plug in for BleadPerl (soon to be Perl 5.10) will get a METRE OF BEER for doing so....
Ill give a bonus prize (to be determined) if the engine ported is the latest TCL engine.
So lets see how long it takes... :-)
Note: I'm going to publish this challenge elsewhere over the next few days. Thanks to AdamK for the idea of the prize.