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

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Mon May 26 20:15:04 UTC 2014


2014-05-26 21:23 GMT+02:00 Nicolas Cellier <
nicolas.cellier.aka.nice at gmail.com>:

>
> 2014-05-26 21:00 GMT+02:00 Bert Freudenberg <bert at freudenbergs.de>:
>
>
>> 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 -
>>
>>
> It would work if only the implementation of Stream was less bloated.
> With current state of code, making it work might have a hard price for low
> reward IMO.
> But I didn't look at exact details of the failure, maybe adding one more
> patch will do it... (until the next bug)
>
>
>
I see no simple hack at first glance
Note that this (Xtreams) one is working OK:

(OrderedCollection new: 3) writing write: #(a b c) asOrderedCollection;
conclusion.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20140526/a4655380/attachment.htm


More information about the Squeak-dev mailing list