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

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

Thread Previous | Thread Next
From:
Ben Morrow
Date:
July 29, 2010 09:29
Subject:
Re: [perl #76756] PATCH: srand returns the seed
Message ID:
20100729162941.GA21967@osiris.mauzo.dyndns.org
Quoth jand@activestate.com ("Jan Dubois"):
> On Wed, 28 Jul 2010, Zefram wrote:
> > Jan Dubois wrote:
> > >Well, you _could_ add a special case to the string comparison:
> > 
> > That would be a mess.  The better solution is for negative zero to
> > stringify as "0".

But that makes number->string->number round-tripping unreliable, which
was the whole reason for stringifying as "-0" in the first place. Lots
of code assumes that stringification preserves information.

> Indeed.
> 
> <not-really-serious>
>   Or add a pragma to tree "-0" as false in boolean context:

Or simply treat negative zero as true? (Giving us yet another "0 but
true" alternative...)

Unless I've badly understood something, negative zeros should be rare
and only produced by people who are expecting them. Given that the
user-visible rule for boolification is 'if it stringifies as "" or "0",
it's false; otherwise it's true' (with the numeric checks just being an
optimisation) I would probably expect something that stringified as "-0"
to be true.

Ben


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