interesting discovery

Ivan Moore ivan at
Fri Nov 11 17:09:26 UTC 1994

Hello Self-interested people,

This mailing list has been a bit quiet - so here's a little something
that I thought was quite interesting.

Want to find out what slots an object needs to define, in order to inherit
from a traits object? (ie. the equivalent of 'subclassResponsibility' and
what 'instance variables' are needed (sorry - that's just Smalltalk speak
to try to make it clearer)

For all methods in the traits object and all the methods it inherits
build up a set of all messages they send to implictSelf (easy to work out from 
the bytecode vector)
(actually its not all messages sent to implicitSelf - you have to take away
those which are arguments or temporary/local slots (whatever they are called))
take away from this the full protocol of the traits object (ie. all the 
messages it understands including those inherited), et voila.

I wrote some code to do this - and it seems to work.
a traits point child needs 'x' and 'y'
a traits dictionary child needs lots of things = 'myKeys:' 'size:' ETC
(they make sense after looking at what slots a dictionary does actually define)

BTW - I realise that there are some improvements that could be made to this
ie. messages sent to explicit self and messages sent to the result of message
sends that return self should be included - but in practice I think what I've
described does a reasonable job.
There is a problem if you go around defining methods of the
form 'x = ( childResponsibility )' !!!


If this isnt clear, sorry. Please tell me and I'll have another go at 
explaining it.
ps. I seem to remember Ole Lehrman Madson asked a similar question when I
met him last summer. Hello Ole, and the rest of the group.

More information about the Self-interest mailing list