6 ms·
I disagree with point A. The old behavior makes a LOT more sense symbolically. I tell you that you have no apples. Write the number of apples you have on a pie
by TylerE 14y ago
I disagree with point A. The old behavior makes a LOT more sense symbolically.
I tell you that you have no apples. Write the number of apples you have on a piece of paper. What did you write? I bet it was 0, not some arbitrary, non-writable symbol for an abstract concept that could mean "nothing" or "error" or "empty" or ..
- steve8918 14y agoI don't agree with your analogy. The question is more similar to "Can you please tell me the number format of <silence>". How can the answer to an unfinished question be "0"? 0 is an actual valid answer, when people are asking for number_format(0, 0). In this case, NULL is definitely more appropriate, because the input is invalid.
- phene 14y agoWhat's the numeric representation of the volume of <silence>? 0 dB
- felipellrocha 14y agoI think you missed the point here. Steve's analogy asks for a number format, not a volume...
- MBlume 14y agoDownvoted for cleverness.
- dpark 14y agoSo you make up a different question to fit the answer you want? Actually that seems about right for PHP.
- mturmon 14y agoSince dB are a log scale, more properly, it would be -Inf dB.
- exDM69 14y ago0 dB = atmospheric pressure. -Inf dB = vacuum of space.
- deleted 14y ago[deleted]
- deleted 14y ago[deleted]
- masklinn 14y ago> he question is more similar to "Can you please tell me the number format of <silence>". Well in PHP, the number for <silence> is 0, so it would stand to reason that the formatted number for <silence> is 0 as well.
- ivix 14y agoOf course, in a more sane language, it would throw an exception, rather than silently returning a wrong value.
- chavesn 14y agoI agree with Steve. "No apples" actually is "0 apples". Your analogy is a misunderstanding of null. Null is like you asking me how many apples Joe has. I say I don't know. If you write down 0, I'm going to stop you and say, "I didn't say zero, I said I don't know."
- jeffdavis 14y agoI tell you that you have "foo" apples. Write the number of apples you have on a piece of paper. What did you write?
- Too 14y agoBOTH behaviors don't make sense. The right behavior is to throw an exception.
- enjo 14y agoAbsolutely agree, and that's PHP's biggest issue. It is constantly doing things like this instead of simply complaining and stopping things down like any sane system would. If I were in charge of PHP, release 6 would be 5.4.4 with the standard library happily throwing exceptions on invalid input. That's it. The language would be 100% more useful instantly.
- eitland 14y agoThis depends on language. Or you'd have to dismiss at least on widely used systems programming language as well. : )
- Too 14y agoWell...if we are allowed to change language completely we could change to a type safe language (as most systems programming are) and we wouldn't have this discussion in the first place since it would be impossible to call the function with a string parameter...
- pelotom 14y agoI tell you you have 12/0 apples. Write the number of apples you have on a piece of paper. Some "functions" are not defined for all inputs. Better to give a "that doesn't make sense" answer than a bogus answer.