Basic inheritance implementation question

Tim Rowledge tim at sumeru.stanford.edu
Tue May 27 04:27:09 UTC 2003


JOEL SHELLMAN <joelhelenshellman at comcast.net> wrote:

> Page 19 of:
> 
> http://coweb.cc.gatech.edu:8888/squeakbook/uploads/noel.pdf
> 
> "Squeak works up the hierarchy until an asString method is encountered.
> If the method is not encountered, then Squeak will return an
> doesNotUnderstand error."
> 
> Is that really so? Does it traverse up the hierarchy instead of using 
> some
> sort of lookup table?
Yes, it really scans up the class hierarchy. 

> Wouldn't that be a performance concern for deep
> hierarchies?
If we weren't clever, yes it could be. Since we cache the results of
lookups (with appropriate interlocking so that changes in the clas
interfaces and shapes cause sensible cache flushing) it isn't a
performance issue at all. We only go up the hierarchy when there is no
cache entry and since individual class method dictionaries tend to be
small (as you noticed, Object isn't one of them!) and class hierachies
aren't often terribly deep (twenty would be pretty unusual) it really
doesn't cost much. It's only a bit of pointer chasing and comparison
anyway.

> Is this standard Smalltalk behavior or is this just how
> Squeak
> does it?
It's definitely standard. The non-standard parts are the details of the
caching systems used. Squeak uses a really simple global cache,
VisualWorks uses inline polymorhpic caches generated in realtime for the
dynamically generated machinecode.

tim
-- 
Tim Rowledge, tim at sumeru.stanford.edu, http://sumeru.stanford.edu/tim
Programmers do it bit by bit.



More information about the Squeak-dev mailing list