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

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Thu Mar 4 21:57:18 UTC 2010


2010/3/4 Levente Uzonyi <leves at elte.hu>:
> 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.
>

{#[1] pointsTo: 1.
#[1] identityIncludes: 1}
-> #(false true)

Not that i care much but...

Nicolas

>
> 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