Simon Percivall wrote:
 > First: It's perfectly simple in Java to create a binary sort that
 > sorts all arrays that contain objects; so wrong there.

My point was that the *same* Java source example, directly converted to 
Python would *automatically* accept all kinds of arrays. No need to make 
any extra efforts. By the way, how would you do it in Java? With 
function overloading? I would not call that perfectly simple.

 > Secondly: The bug has nothing to do with static typing (I'm guessing
 > that's what you meant. Both Python and Java are strongly typed). The
 > problem is that ints are bounded in Java. They could easily have been
 > ints and then automatically coerced to (equivalent to) longs when they
 > got bigger; that they aren't is more a design fault than anything to
 > do with static typing. The equivalent in Python would have been if an
 > overflow exception was raised when the int got too big. It might have
 > been that way, typing or no typing.

Yes, sorry, I meant static typing, not strict typing. But I still do 
think that the bug has to do with static typing. You're right, the 
direct cause is that ints are bounded in Java, and not bounded in 
Python, and that it could well be the other way round. However, doing it 
the other way round would not be so clever and appropriate for the 
respective language due to the difference in static typing.

Java could coerce the result to long, but then it would still crash when 
the result is stored back to the statically typed variable. So that 
would not be very clever.

And Python could produce an overflow error (and did in the past), but 
taking advantage of the possibilities of dynamic typing and 
automatically producing longs is a cleverer solution for Python, and 
that's why it was proposed and accepted in PEP237.

So the difference in static typing is actually the deeper reason why 
ints were made to behave differently in the two languages.

-- Christoph
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to