[squeak-dev] #streamContents: on OrderedCollection broken?
Bert Freudenberg
bert at freudenbergs.de
Mon May 26 19:00:45 UTC 2014
On 2014-05-26, at 18:40, Levente Uzonyi <leves at elte.hu> wrote:
> 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
Still, it should work, don't you think?
- Bert -
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4142 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140526/fbae239c/smime.bin
More information about the Squeak-dev
mailing list
|