[squeak-dev] The Trunk: Kernel-ul.604.mcz

Levente Uzonyi leves at elte.hu
Tue Jul 12 18:54:37 UTC 2011


On Tue, 12 Jul 2011, Chris Muller wrote:

> I need to test it, but this looks like it will hurt me.  I have
> subclassed LargePositiveInteger but I need it to compare equally - but
> with this hard class-check it will now fail....

Subclassing these classes sounds like a bad idea in general. Doesn't 
encapsulation fit your needs?

Anyway, the simplest solution is to replace the aNumber class == self 
class check with aNumber negative == self negative and: [ aNumber isLarge 
== self isLarge ].


Levente

>
> On Sun, Jul 10, 2011 at 9:36 AM,  <commits at source.squeak.org> wrote:
>> Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
>> http://source.squeak.org/trunk/Kernel-ul.604.mcz
>>
>> ==================== Summary ====================
>>
>> Name: Kernel-ul.604
>> Author: ul
>> Time: 10 July 2011, 4:36:20.467 pm
>> UUID: f758876f-a507-404b-aa2f-2c1038504b48
>> Ancestors: Kernel-bf.603
>>
>> Optimized Integer >> #= for integer-integer comparisons. Return false for integers from different classes without further checking.
>>
>> =============== Diff against Kernel-bf.603 ===============
>>
>> Item was changed:
>>  ----- Method: Integer>>= (in category 'comparing') -----
>>  = aNumber
>> +
>> +       aNumber isInteger ifTrue: [
>> +               aNumber class == self class ifFalse: [ ^false ].
>> +               ^(self digitCompare: aNumber) = 0 ].
>> +       aNumber isNumber ifFalse: [ ^false ].
>> +       ^aNumber adaptToInteger: self andCompare: #=!
>> -       aNumber isNumber ifFalse: [^ false].
>> -       aNumber isInteger ifTrue:
>> -               [aNumber negative == self negative
>> -                       ifTrue: [^ (self digitCompare: aNumber) = 0]
>> -                       ifFalse: [^ false]].
>> -       ^ aNumber adaptToInteger: self andCompare: #=!
>>
>>
>>
>
>


More information about the Squeak-dev mailing list