develooper Front page | perl.perl5.porters | Postings from April 2008

Re: bug or not? constants warn only once

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
April 24, 2008 10:39
Subject:
Re: bug or not? constants warn only once
Message ID:
20080424173935.GI79799@plum.flirble.org
On Thu, Apr 24, 2008 at 07:23:50PM +0200, H.Merijn Brand wrote:

> > The implementation caches the numeric result, and uses that next time round,
> > before it gets a chance to warn. It's been this way since (at least) 5.005_03
> > (which is the oldest perl I have hanging around)
> > 
> > So is this a bug? Advice from Klortho #11943 suggests not:
> 
> Not a bug. I recall relying on this behaviour somewhere to speed up
> loops. When you add 0 to a string value, it fills the IV/NV, so inside
> the loop it doesn't have to convert.

Oh, I didn't mean that the caching was a bug. No, caching is key.
I meant that not warning felt buggy.

Although, this is a simpler example:

$ ./perl -lwe '$a = "Pie"; print 0 + $a; print 0 + $a'
Argument "Pie" isn't numeric in addition (+) at -e line 1.
0
0

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