Re: method overriding
From: Sebastian Millies (s.millies_at_REPLACE-CAPS.idsMINUSscheerDOTde)
Date: 03/22/04
- Next message: Dale King: "Re: Interface question"
- Previous message: Christophe Vanfleteren: "Re: System.setProperties() persistence"
- In reply to: Neal Gafter: "Re: method overriding"
- Next in thread: Dale King: "Re: method overriding"
- Reply: Dale King: "Re: method overriding"
- Reply: Neal Gafter: "Re: method overriding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 22 Mar 2004 15:42:53 +0100
this maybe off-topic for this discussion, but *why* has
Java chosen to
a) define the signature of a method as not including the return type?
b) not consider subtype-relationships in the definition of overriding?
That is, what are the (historical) reasons for having
Child Child.method(Child)
not override
Parent Parent.method(Parent)
In my view, that would be so much easier to understand!
(It would be similar to strongly typed functional languages
like ML, where a method's type is described as a function
from the argument types to the result type. The function denotes
a set, and subtype relationships map directly to subset relationships
in the model. Nothing like that is possible for Java, in fact, I haven't
yet seen a semantics for Java ...).
And it wouldn't be any more complex intuitively either: Child.method
would override Parent.method if all slots in the child method's signature
were at least as narrow as those in the parent method's.
Well, I guess we'd have less runtime type checking, because the
legality of the method call in e. g.
Parent p = (Parent) new Child;
Child c = Child.method( p );
could only be determined on the basis of p's runtime type. But I guess
I'd still like that better than what's happening in Java.
-- Sebastian
"Neal Gafter" <gafter@spamcop.net> schrieb im Newsbeitrag
news:405E93CD.4020103@spamcop.net...
> Chris Uppal wrote:
> [snip]
>> Child Child.method(Child) does not override Parent
Parent.method(Parent)
>
> Simple: overriding is by signature, which is method name and argument
types.
> The same way you always explained it. What's the problem?
> [snip]
- Next message: Dale King: "Re: Interface question"
- Previous message: Christophe Vanfleteren: "Re: System.setProperties() persistence"
- In reply to: Neal Gafter: "Re: method overriding"
- Next in thread: Dale King: "Re: method overriding"
- Reply: Dale King: "Re: method overriding"
- Reply: Neal Gafter: "Re: method overriding"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|