why python annoys me
Alex Martelli
aleaxit at yahoo.com
Thu Apr 19 07:35:10 EDT 2001
"D-Man" <dsh8290 at rit.edu> wrote in message
news:mailman.987629727.6736.python-list at python.org...
> On Wed, Apr 18, 2001 at 01:43:54PM +0200, Martin von Loewis wrote:
> | neelk at alum.mit.edu (Neelakantan Krishnaswami) writes:
> |
> | > Hi Paul, I think I will have to disagree with you on this point. ints
> | > and arrays are not objects in Java, whereas the corresponding things
> | > in Python are.
> |
> | This is OT, but arrays in Java are objects. You create them with new,
> | they follow an inheritance hierarchy, can be polymorphically passed
> | where Object is allowed, and support introspection.
>
> They are objects (of a sort, more like a C struct IMO), but they do
> not inherit from java.lang.Object and thus can't be passed to a method
> that wants a java.lang.Object.
Not in the Java I know.
> Also where is the inheritance hierarchy for arrays you mentioned?
In Java, if X inherits from Y, then array-of-X inherits from array-of-Y.
This, given mutability, is unfortunately wrong, and breaches Java's
compile-time type-safety: you can pass an array-of-X to a method
as an array-of-Y argument, and the method then tries to stick into
the array a Y instance (compile-time correct) that is not an X --
and you get a runtime type violation (specs mandate that a specific
exception be raised for this, fortunately, so you don't get random
undiagnosed errors as you might for similar array bloopers in C++).
Alex
More information about the Python-list
mailing list