develooper Front page | perl.moose | Postings from December 2010

Re: [PATCH] Test for RegexpRef type constraint via ->isa

Thread Previous | Thread Next
From:
Florian Ragwitz
Date:
December 31, 2010 11:25
Subject:
Re: [PATCH] Test for RegexpRef type constraint via ->isa
Message ID:
87k4ip9257.fsf@tardis.home.perldition.org
David Leadbeater <dgl@dgl.cx> 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.


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About