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

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

Thread Previous | Thread Next
From:
Jan Dubois
Date:
August 2, 2010 10:49
Subject:
RE: [perl #76756] PATCH: srand returns the seed
Message ID:
036f01cb326b$1597a3e0$40c6eba0$@activestate.com
On Mon, 02 Aug 2010, Zefram wrote:
> 
> Nicholas Clark wrote:
> >And so we go full circle, as you removed the code demonstrating that we
> >already have that bug, only worse:
> 
> Yes.  We should fix that bug, not do it intentionally.

I don't see agreement on what the bug is anymore:

a) Should -0 always be TRUE, even when it has never been stringified, or
b) Should -0 always be stringified as "0" and therefore always be FALSE?

I can see arguments for both, as neither of them is completely "correct"
from at least some points of view.

I would tend to prefer b), given that it is really easy to lose that minus
sign on your zero anyways:

$ perl -MDevel::Peek -e '$a = "-0"; $b = $a + 1.0; Dump $a'
SV = PVIV(0x820204) at 0x825df0
  REFCNT = 1
  FLAGS = (IOK,POK,pIOK,pPOK)
  IV = 0
  PV = 0x201b80 "-0"\0
  CUR = 2
  LEN = 16

$ perl -MDevel::Peek -e '$a = "-0"; $b = $a + 1.1; Dump $a'
SV = PVNV(0x802bac) at 0x825df0
  REFCNT = 1
  FLAGS = (NOK,POK,pNOK,pPOK)
  IV = 0
  NV = -0
  PV = 0x201b80 "-0"\0
  CUR = 2
  LEN = 16

But I guess you can view this as just another bug.

Cheers,
-Jan



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