When does a bug turn into a feature?
When does a bug turn into a feature?
Posted Jan 15, 2010 21:05 UTC (Fri) by flewellyn (subscriber, #5047)In reply to: When does a bug turn into a feature? by mrshiny
Parent article: When does a bug turn into a feature?
First, passing uninitialized variables into functions. Every variable should always be initialized to a value that is sensible for what it will be used for! It's true that PHP does not enforce this as strictly as some other dynamic languages do (Python and Common Lisp come to mind), but it's still terrible practice.
But second, and even worse, endosquid was apparently relying on undefined behavior! The documentation for number_format() does not specify what happens if you pass in a non-numeric value as its first argument, and while we could wish that said docs explicitly said "this behavior is undefined", the fact remains that it DOES say the first argument must be a float. Yes, in the past, passing in some other value resulted in "0", but the whole point of undefined behavior is that it cannot be relied upon.
Posted Jan 16, 2010 11:04 UTC (Sat)
by addw (guest, #1771)
[Link]
I suppose that one can at least assume that ''if the documentation doesn't say what happens, then assume that it is undefined -- don't rely on it''.
But at least PHP does have reasonably complete end user documentation, which is better than can be said (unfortunately) for PEAR.
When does a bug turn into a feature?
while we could wish that said docs explicitly said "this behavior is undefined"
It was things like this that turned the C language definition from a slim K & R into something the size of a telephone directory. The trouble is that everyone read K & R but few read the full standard.