develooper Front page | perl.perl5.porters | Postings from August 2010

Re: [perl #76756] PATCH: srand returns the seed

Thread Previous | Thread Next
From:
Nicholas Clark
Date:
August 2, 2010 07:44
Subject:
Re: [perl #76756] PATCH: srand returns the seed
Message ID:
20100802144442.GU48531@plum.flirble.org
On Mon, Aug 02, 2010 at 03:41:21PM +0100, Zefram wrote:
> Nicholas Clark wrote:
> >I can see one potential crafty way to avoid the above inconsistency, which
> >is to change sv_2pv_flags() so that it doesnt (completely) cache the string
> >conversion for -0.
> 
> Eww.  This would violate the truth value rule, by having something that
> stringifies as "-0" but is false.  Don't do it.

And so we go full circle, as you removed the code demonstrating that we
already have that bug, only worse:

$ perl -wle '$a = 0/-1; print $a ? "T" : "F"; print $a; print $a ? "T" : "F"'
F
-0
T

because we already have it that something that stringifies as -0 may or may not
be false depending on side effects of reading it.

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