[squeak-dev] Re: Object>>#is:? (was: Re: PackageDependencyTest)

Juan Vuletich juan at jvuletich.org
Thu Mar 4 20:42:15 UTC 2010

Stéphane Rollandin wrote:
> ...
> let's now consider MySpecializedMorph, a subclass of MyMorph that I 
> *do not* want to be considered as MyMorph:
> is: aSymbol
>     (super is: aSymbol and: [aSymbol =~ #MyMorph])
>         or: [aSymbol == #MySpecializedMorph]) ifTrue: [^ true].
>     ^ false
> see the problem ?

Yes, I see it. As I see it, #is: is for asking about conformance to a 
certain protocol. And your MySpecializedMorph does know what protocols 
it conforms. So it can implement something like:

is: aSymbol
    aSymbol == #Morph ifTrue: [^true].
    aSymbol == #MySpecializedMorph ifTrue: [^true].

without calling super. Please not that in Cuis, #is: does not call 
#isKindOf: at all.

Juan Vuletich

> I have to be aware of the behavior of each implementation of #is: in 
> the upward inheritance chain if I want to produce the proper tests. 
> Going down, those tests will become more and more complex and hard to 
> grok. Plus, reimplementing any of the #is: can possibly break any of 
> the #is: in subclasses. So all #is: implementations in a given 
> hierarchy are actually dependent. It's pure spaghetti code, as far 
> away from OOP as it gets.
> I guess I'm missing something. how is this supposed to work ?
> Stef

More information about the Squeak-dev mailing list