[squeak-dev] Re: Why is Heap>>#species => Array?
Klaus D. Witzel
klaus.witzel at cobss.com
Thu Feb 21 21:41:28 UTC 2008
On Thu, 21 Feb 2008 22:06:28 +0100, nicolas cellier wrote:
> Klaus D. Witzel a écrit :
>> Subject line says it all, check yourself,
>> (Heap withAll: 'array') reject: [:x | x = $r]
>> What's the rationale (there's no doc, no comment)? Archive shows that
>> #species was changed to fix another (anonymous) bug but, this way the
>> senders of #species can impossibly do what Smalltalk users expect from
>> the collection hierarchy (and there is #asArray ...)
>>
>
> I have not the background to answer you.
> All I can tell is that this triggers another associativity failure:
>
>
> | anArray heap1 heap2 |
> anArray := #(1 2 3).
> heap1 := Heap withAll: (1 to: 3) sortBlock: [:a :b | a < b].
> heap2 := Heap withAll: (1 to: 3) sortBlock: [:a :b | b > a].
> (heap1 = anArray) & (heap2 = anArray) ==> (heap1 = heap2)
>
> Heaps do compare their sortBlock.
And no Array compares to a Heap, heap invariantly supers #= to
SequenceableCollection.
> They are more relax when comparing with their species.
IC what you mean but, #species is invariant in their #= and their super #=.
> This is minor, but note nice.
It breaks all users of #species (#collect:, #reject:, #inject:, etc, all
the powerful things in collection hierarchy); let's not call it minor then
:)
> Nicolas
>
>> -
>> http://lists.squeakfoundation.org/pipermail/squeak-dev/2000-March/011043.html
>> /Klaus
>> P.S. Heap is used in not-so-uncritical parts, like
>> #startTimerEventLoop and WorldState, so I don't want to "just" play
>> with Heap's #species without any background info on what was fixed.
>>
>
>
>
More information about the Squeak-dev
mailing list
|