[squeak-dev] Re: Why is Heap>>#species => Array?

nicolas cellier ncellier at ifrance.com
Thu Feb 21 21:56:15 UTC 2008


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 think this is mainly because of collect:

Since collect: will potentially change class of elements, it would make 
sortBlock: fail.


	| heap |
	heap := Heap withAll: (1 to: 10).
	self shouldnt: [heap collect: [:e | e even]] raise: Error.

Of course, another solution like adopted in SortedCollection would be to 
define Heap>>collect: rather than Heap>>species.

But there might be other reasons...

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