It could be argued that the way to implement "enhanced" strings, eg
strings with embedded attributes (html, rtf,....) is for someone
to write a specific SV class to deal with that kind of string.
As has been pointed out, a difficulty with this is that standard
regexes must be able to operate on that SV, leading to all sorts of
problems related to the extraction of the string representation,
and the definition of the semantics of matching and substituting on
that string.

One way round this is to leave the semantics to implementor of the SV type.
This could be done by having vtable methods for *all* string ops
known to Perl; in particular m//, s// and tr//.

The way this could work is for the Perl core to provide a generic regex
library, which uses only the public interface to SVs to extract
and manipulate its contents. Standard string SVs would have the relevant
vtable entries point to these generic regex functions.
However, if someone wants to implement a HTML SV type say, then
(if they are keen enough) they can write their own m//, s// methods
which are efficent (becuase they can access the internal representation),
and can have whatever semantics the author wishes.

However, since the internals of regexes are a dark art to me, I dont know
whether is is sensible to have a single regex compiler, but multiple
regex executors (if that's the right terminology).

Reply via email to