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

Levente Uzonyi leves at elte.hu
Thu Mar 4 21:50:50 UTC 2010


On Thu, 4 Mar 2010, Bert Freudenberg wrote:

> On 04.03.2010, at 22:21, Stéphane Rollandin wrote:
>>
>>> If you have a lot of protocols you can use the super fast
>>> primitive supported #pointsTo: and have a lot cleaner (and possibly
>>> faster) code:
>>>
>>> is: aSymbol
>>>
>>>  	^#(Morph MySpecializedMorph FooMorph BarMorph) pointsTo: aSymbol
>>>
>>
>>
>> wow. thanks for the pointer, I wasn't aware of this one :)
>>
>> Stef
>
> It's also less readable. If you replace #pointsTo: with #includes: I know right away what it means. If you use this low-level optimization I have to think twice which object points where.

#includes: is a lot slower of course, that's why #pointsTo: is used in 
MethodDictionary >> #includesKey:. We also have #identityIncludes: which 
is not so fast, but could be overridden in SequenceableCollection for 
better performance.


In Cuis #is: could be implemented only in Object as something like

#is: aSymbol
 	"#pointsTo: is used here for better performance"

 	^self implementedProtocols pointsTo: aSymbol

and #implementedProtocols could just return a literal Array, though it's 
has an extra message send.


Levente

>
> - Bert -
>
>
>
>


More information about the Squeak-dev mailing list