[squeak-dev] #streamContents: on OrderedCollection broken?

Levente Uzonyi leves at elte.hu
Mon May 26 16:40:44 UTC 2014


On Mon, 26 May 2014, Marcel Taeumel wrote:

> Should this work?
>
> OrderedCollection streamContents: [:result |
> 	result nextPutAll: #(a b c) asOrderedCollection].
>
> Well, this works:
>
> OrderedCollection streamContents: [:result |
> 	result nextPutAll: #(a b c)].
>
> And this works, too:
>
> OrderedCollection streamContents: [:result |
> 	result nextPut: #foo; nextPutAll: #(a b c) asOrderedCollection].

Even if it would work, it's a bad pattern, don't use it. OrderedCollection 
implements its own streaming API (#add:, #addAll:), which is a lot more 
efficient. I would use the same API as in streams in my own Smalltalk, but 
that's another story.

Also, converting Arrays to OrderedCollections just to throw them away in 
the next step is just as bad as creating a stream over an 
OrderedCollection. Don't do it.


Levente

>
> Best,
> Marcel
>
>
>
> --
> View this message in context: http://forum.world.st/streamContents-on-OrderedCollection-broken-tp4760369.html
> Sent from the Squeak - Dev mailing list archive at Nabble.com.
>
>


More information about the Squeak-dev mailing list