Boolean expressions (was: Re: [squeak-dev] Re: Object>>#is:? (was:
leves at elte.hu
Thu Mar 4 21:07:21 UTC 2010
On Thu, 4 Mar 2010, Juan Vuletich wrote:
> 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].
I don't get you guys, why do these expressions have to be so
complicated? Just compare this with those above:
^aSymbol == #Morph or: [ aSymbol == #MySpecializedMorph ]
If you have a lot of protocols you can use the super fast
primitive supported #pointsTo: and have a lot cleaner (and possibly
^#(Morph MySpecializedMorph FooMorph BarMorph) pointsTo: aSymbol
> 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 ?
More information about the Squeak-dev