OT - Bizarre PHP problem/bug
amcnabb at mcnabbs.org
Sat Nov 27 09:29:18 MST 2010
On Mon, Nov 22, 2010 at 05:56:09PM -0700, Tod Hansmann wrote:
> Not "broken" just one of the many cases that duck typing has to handle
> some way or another, and however it handles it will not work in all
> cases. You have the same cases in any loosely typed language.
I'm with Michael on this one. I have come across many hard-to-debug
problems caused by PHP and Perl being far too loose when interpreting
strings as numbers. Automatically interpreting strings as numbers would
violate at least 3 principles from the Zen of Python (a duck typed but
strongly typed language):
Explicit is better than implicit.
Errors should never pass silently.
In the face of ambiguity, refuse the temptation to guess.
> Granted, in this particular case we think it should behave
> differently, but if it did, that would break different cases, or be
> slower, or whatever tradeoff they weren't willing to make.
Of course, as you suggest, there is a good argument that Python is wrong
in this case, too:
(On the statement print "42 monkeys"+"1 snake") BTW, both Perl and
Python get this wrong. Perl gives 43 and Python gives "42 monkeys1
snake", when the answer is clearly "41 monkeys and 1 fat snake".
- Jim Fulton, 10 Aug 1999
Fun stuff. :)
PGP Fingerprint: 8A17 B57C 6879 1863 DE55 8012 AB4D 6098 8826 6868
More information about the PLUG