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

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

Thread Previous
Father Chrysostomos via RT
February 1, 2012 22:25
[perl #109542] $1 handled differently in integer arithmetics
Message ID:
On Wed Feb 01 16:48:59 2012, demerphq wrote:
> On 2 February 2012 00:48, Zefram <> 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

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About