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

[perl #109542] $1 handled differently in integer arithmetics

Thread Previous
From:
Father Chrysostomos via RT
Date:
February 1, 2012 22:25
Subject:
[perl #109542] $1 handled differently in integer arithmetics
Message ID:
rt-3.6.HEAD-14510-1328163924-310.109542-15-0@perl.org
On Wed Feb 01 16:48:59 2012, demerphq wrote:
> On 2 February 2012 00:48, Zefram <zefram@fysh.org> wrote:
> > demerphq wrote:
> >> � � � � � � � � � � � � � � � � � � � �Why don't we just copy the
> >>values and be done with the bugs?
> >
> > Performance. �I'd be happy to lose a bit of performance for saner
> > behaviour, but Reini will argue vehemently against it. �Between the
> > two of us you'll find a range of opinions about which optimisations are
> > worth the hassle.
> 
> I don't think this would actually be slower. I suspect it would be
> faster, and make scripts that use the evil three $`, $&, $' much
> faster.

By dividing PL_sawampersand into three variables to avoid copying the
whole string?  I think that would make things more buggy.

> 
> Right now the rules for copying the string are that we copy it in
> entirety if we see $1 or $2 in the pattern or have seen the evil three
> anywhere in the script.
> 
> Anyway, I realized after i posted that LVALUES dont quite match, as
> they dont preserve the LVALUE string when the target variable is
> undef()'ed, or modified. If we could figure out a clean way to make
> that happen, then the overhead would only be the creation of the
> LVALUE SV, but we would eliminate a lot of string copying. AFAIK,
> there have been a number of attempts  to add copy-on-write behaviour
> to eliminate this copying and it has never quite worked out, and im
> thinking that maybe LVALUE provides a neat way to make it work.

But LVALUEs are magical.  That’s how they work.

And we would still have this same bug with tied variables, I believe. 
So changing $1 won’t solve this problem.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org:443/rt3/Ticket/Display.html?id=109542

Thread Previous


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