David Leadbeater <[email protected]> writes:

> On 31 Dec 2010, at 18:41, Florian Ragwitz wrote:
>> The specialness of regexp refs mostly comes from either having an SV
>> type of SVt_REGEXP on new perls, or from PERL_MAGIC_qr on older
>> perls.
>
> That's what I was getting at with my reftype comment, I've just
> realised re::is_regexp exists which is probably the 'right' way of
> doing this, except this doesn't exist before perl 5.10 by the look of
> it :(
>
> So maybe it needs a bit of XS code that calls SvRXOK to support 5.8
> (or just use ->isa('Regexp') on 5.8?)

Something like mg_find(SvRV(sv), PERL_MAGIC_qr) should do fine on older
perls. While we're in C space anyway, we might want do
SvTYPE(SvRV(sv)) == SVt_REGEXP as well, as that's quite a bit cheaper
than reftype.

Attachment: pgp1Y4j9J1kmN.pgp
Description: PGP signature

Reply via email to