develooper Front page | perl.perl5.porters | Postings from January 2012

Re: [perl #108780] overload::StrVal and qr//

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
January 25, 2012 07:46
Subject:
Re: [perl #108780] overload::StrVal and qr//
Message ID:
20120125154617.GO9069@plum.flirble.org
On Sun, Jan 22, 2012 at 11:36:32PM +0100, demerphq wrote:

> Wonder what Nicholas says.

Nicholas continues to apologise for answering his e-mail backlog in an
odd order, and is aware that there's stuff from the past $n weeks and longer
that is overdue for a reply.

On Sun, Jan 22, 2012 at 02:50:54PM -0800, Father Chrysostomos wrote:
> 
> On Jan 22, 2012, at 2:37 PM, yves orton via RT wrote:
> 
> > On 22 January 2012 21:57, Father Chrysostomos <perlbug-followup@perl.org> wrote:

> >> According to the overload documentation, overload::StrVal returns the string that "" would return in the absence of string overloading.
> >> 
> >> But this isn?t actually the case:
> >> 
> >>    $\ = "\n";
> >>    use overload;
> >>    no overloading;
> >>    print qr//;                   # prints (?^:)
> >>    print overload::StrVal(qr//); # prints Regexp=REGEXP(0x803e50)
> >> 
> >> qr// thingies are not actually using overloading.
> > 
> > They used to I think. And I think they should act like they are.

> $ perl5.6.2 -le 'use overload; print overload::StrVal qr//'
> Regexp=SCALAR(0x800264)
> 
> It seems they have always been weird.

IIRC stringification of regexps was always implemented by special case code
in sv.c. When I was making them first class, I wondered whether it would be
better to remove it by giving them overloaded stringification instead, but
everything seemed complex enough already without adding this to it, so I
didn't.


It might still be "worth it" to change them to using overloading. However,
everything using the plug in API would have to change too, I think, else
it wouldn't stringify as before.

Nicholas Clark

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