in reply to Re^4: Determining whether a value is zero. (logic)
in thread Determining whether a value is zero.
His own impression that the declaring of "" and "0" as the only false strings being a highly arbitrary decision also hints that he has some seriously flawed mental model of how Perl works.Oh, the amount of things you can deduce from a person based on reading a reply, and being completely ignorant of the post he's replying to.
It was BrowserUK that came with Any definition that deems "0" as zero, but "00", "0.0" & "0 " as not, is so arbitrary. I'm merely pointing out that of "0", "00", "0.0" & "0 ", Perl uses the same arbitraryness to group them in true/false categories.
Let me spell it out:
| Value | Perl's Truthness | My Challenge |
|---|---|---|
| "0" | false | zero |
| "00" | true | non-zero |
| "0.0" | true | non-zero |
| "0 " | true | non-zero |
I also noticed that Perl sets SvIOK (and SvIOKp, of course) for $x= '0 '; 0+$x; (note the trailing space), which I suspect JavaFan finds unfortunate.Well, duh. I know that. You might think I have "some seriously flawed mental model of how Perl works", but I do know that 0 + $x actually may modify $x. Heck, even $x == 0 modifies it.
But this, of course, considers "00", "0.0", and "0e0" as being zero (as it should)As it should? Not really. My challenge, my rules. Why do people keep insisting that the asked for subroutine should return the same results for "0", "00", and "0.0", because it's otherwise illogical, while there are functions/operators in Perl that treat them differently and noone complains they are illogical (not, !, but also length).
|
|---|