method dictionary lookups and walking up the inheritance tree

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

method dictionary lookups and walking up the inheritance tree

Michael Haupt-3
Hi,

once more, apologies for cross-posting.

>From ClassBuilder, I could see that, when a new class is created, the
superclass's method dictionary contents are copied to the method
dictionary of the new class. Still, the interpreter climbs, in
Interpreter>>lookupMethodInClass:, up the inheritance tree to resolve
a method.

Why is that? Have I missed a spot where subclass creation does not
entail method dictionary copying?

Thanks,

Michael

Reply | Threaded
Open this post in threaded view
|

Re: method dictionary lookups and walking up the inheritance tree

timrowledge

On 16-May-06, at 9:06 AM, Michael Haupt wrote:

> Hi,
>
> once more, apologies for cross-posting.
>
>> From ClassBuilder, I could see that, when a new class is created, the
> superclass's method dictionary contents are copied to the method
> dictionary of the new class. Still, the interpreter climbs, in
> Interpreter>>lookupMethodInClass:, up the inheritance tree to resolve
> a method.
>
> Why is that? Have I missed a spot where subclass creation does not
> entail method dictionary copying?
I think you must have misunderstood something in the code, unless of  
course the code has a bug.

Each class has its own method dictionary (and the metaclass has its  
of course) and the methods in the dictionary are those belonging to  
the class alone. If we copied methods down from the superclass you  
would find that a class such as MultiCompositionScanner would have a  
method dict of size (in my 3.8 based image) of 610 instead of the 21  
that it actually has. And of course, we wouldn't be going up the  
class tree in the VM.

Have you perhaps confused adding a new class with mutating an old  
one, where we do indeed 'copy' methods but from the old to the new?


tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
All computers run at the same speed...with the power off.



Reply | Threaded
Open this post in threaded view
|

Re: method dictionary lookups and walking up the inheritance tree

Michael Haupt-3
Hi Tim,

On 5/16/06, tim Rowledge <[hidden email]> wrote:
> I think you must have misunderstood something in the code, unless of
> course the code has a bug.

when in doubt, the former applies. :-)

> Have you perhaps confused adding a new class with mutating an old
> one, where we do indeed 'copy' methods but from the old to the new?

Apparently, I have indeed confused the two, thanks for pointing this out.

Best,

Michael