[squeak-dev] Traits as a way of defining an interface instead of an abstract superclass

Frank Shearar frank.shearar at gmail.com
Fri Oct 12 16:26:27 UTC 2012


On 12 October 2012 17:21, Chris Cunnington
<smalltalktelevision at gmail.com> wrote:
> I've been looking at MetaObjects's [1] decade old implementation of the vm
> in Cocoa. It has a class called SqueakInterpreter.h that defines a protocol
> that is used in SqView. The selectors are listed in SqueakInterpreter.h but
> implemented in SqView.m. I believe this kind of thing is now called a
> category in Objective-C-ese. And I was wondering why somebody would do this?
> We don't separate the protocols from the classes in Smalltalk. And I think
> the reason is we use abstract superclasses. And we have deep user developed
> hierarchies.

Protocols allow you to say "these messages, unrelated by inheritance,
nevertheless both understand these sets of messages". That's very
handy, because sometimes you can't or don't want an inheritance
relationship between the two classes.

Perhaps the classes both come from 3rd party libraries, and you're
writing something that should be able to operate on both, and want to
express that in THIS LIMITED way, the classes are similar.

frank

> Chris


More information about the Squeak-dev mailing list