Scott Bronson writes:

> On Thu, 2004-06-24 at 08:04, Jonadab the Unsightly One wrote:
> 
> > > In Perl5, the following values are FALSE: undef, '0', 0, and ''.
> 
> > ... The really special case is '0', which is false for arcane (but
> > very sensible) reasons.
> 
> I don't agree that '0' being false is sensible.

But you're fine with 0 being false?  0 and '0' are pretty much
interchangeable in Perl 5 -- wherever you can use one, you can use the
other and it gets coerced to it.  So it really wouldn't make sense to
have them being treated differently for truth purposes.

> As a related question, why is "0" false, but "0.0" is true?  Floats
> are second-class citizens?

'0' is the string representation of zero.  0.0 is also zero.  But 0 and
0.0 (and 0x0000, and 2 - 2, and ...) are all the same zero, and all
stringify to '0'.  '0.0' is not a representation of that same zero; it's
a string that would evaluate to zero if converted to a number, but it
isn't interchangeable with the other zeros.

If you think '0.0' should be false, what about '0x0000' or '2 - 2' or
'$x - $x'?

Smylers

Reply via email to