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

Re: bug or not? constants warn only once

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
April 25, 2008 00:06
Subject:
Re: bug or not? constants warn only once
Message ID:
20080425090639.461bac3e@pc09.procura.nl
On Thu, 24 Apr 2008 18:39:35 +0100, Nicholas Clark <nick@ccl4.org>
wrote:

> 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.

Then I wasn't verbose enough too, as I think it should warn once and
only once. Maybe until either value changes.

Also think dualvar. I use that, and I'd hate all my error messages to
suddenly start warning in numeric context.

> 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

-- 
H.Merijn Brand         Amsterdam Perl Mongers (http://amsterdam.pm.org/)
using & porting perl 5.6.2, 5.8.x, 5.10.x  on HP-UX 10.20, 11.00, 11.11,
& 11.23, SuSE 10.1 & 10.2, AIX 5.2, and Cygwin.       http://qa.perl.org
http://mirrors.develooper.com/hpux/            http://www.test-smoke.org
                        http://www.goldmark.org/jeff/stupid-disclaimers/

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