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

Chris Cunnington smalltalktelevision at gmail.com
Fri Oct 12 16:42:49 UTC 2012


On 12-10-12 12:26 PM, Frank Shearar wrote:
> 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".
There's something dicey about this wording, I feel. Messages don't 
understand messages. Objects do. "These objects, unrelated by 
inheritance, nevertheless both understand these sets of messages." Perhaps?

>   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.
>
Yea, that makes sense. And it's illustrated by the vm source I've been 
looking at. SqueakInterpreter.h is going to be the same no matter the 
platform. The implementation in the view class will depend on the 
operating system. I think there's a lot of that going on in 
SqueakPureObjc.xcodeproj vm code with categories like:

sqSqueakOSXApplication+imageReadWrite.m
sqSqueakOSXApplication+events.m
sqSqueakOSXApplication+attributes.m
sqSqueakOSXApplication+cursor.m

That makes your point, I think.

So what we're talking about is scale. "Few people" using a code base as 
opposed to "many people". Now that you say it, I suppose Cincom address 
this because they make an enterprise Smalltalk. And I guess namespaces 
come into this domain of many users.

Chris


More information about the Squeak-dev mailing list