Reputation: 14858
Assume object
is an instance of class C
. Also assume that object
has an instance-specific method m
attached to it. The method m
is defined in both C
and its superclass C0
. The question is, which method should the expression
super m
invoke when self == object, and why?
I see two possible answers:
EDIT
Even though the way we implement instance-specific behavior shouldn't matter for the semantics of super
, let me point out that my favorite implementation is the one that places the so called MethodDictionaryArray
(or MDA
for short) in object headers, instead of the object class. As you can imagine, a MDA
contains the method dictionaries of the inheritance chain.
With this implementation you can put instance behavior in a new MethodDictionary
(MD
) and redefine the object's MDA as the nested array #{MD. MDA}
.
Upvotes: 1
Views: 134
Reputation: 143
It seems to me that one can phrase the definition a bit differently,
to get at the proper resolution of the semantics.
If we consider the normal case to be equivalent to
'do not include in the search any methods that are defined by the receiver, include only those which are inherited'
then the implementation details are not required
when we are
deciding which answer to expect.
Upvotes: 0
Reputation: 2847
The standard definition of super is that super sends a message to the same receiver as self but starts the method lookup in the class above the one where the current method is defined.
Upvotes: 1
Reputation: 4623
IMHO it should invoke C0>>m
to behave just like 'normal' instances of C
. The implementation detail of how the instance-specific behavior is realized shouldn't matter. If you copy a method from C
to its instance, it should ideally behave exactly the same as before.
Upvotes: 4