[squeak-dev] Re: Re: OrderedCollection and asOrderedCollection

Louis LaBrunda Lou at Keystone-Software.com
Wed Jul 18 22:08:17 UTC 2012


In VA Smalltalk OrderedCollection>asOrderedCollection answers a copy and it
looks like it has done so since mid 1996.

Lou

On Wed, 18 Jul 2012 14:45:44 -0700, Bert Freudenberg <bert at freudenbergs.de>
wrote:

>
>On 18.07.2012, at 14:40, Frank Shearar wrote:
>
>> On 18 July 2012 22:33, Bert Freudenberg <bert at freudenbergs.de> wrote:
>>> On 18.07.2012, at 14:08, Frank Shearar wrote:
>>> 
>>>> Is there any particular reason why we don't have OrderedCollection >>
>>>> #asOrderedCollection simply return self?
>>>> 
>>> 
>>>> Right now (OrderedCollection with: 1) asOrderedCollection calls
>>>> Collection >> #asOrderedCollection, which calls self as:
>>>> OrderedCollection, which copies the collection.
>>>> 
>>>> This would also make OrderedCollection work a bit more like Array -
>>>> Array >> #asArray simply returns self.
>>>> 
>>>> frank
>>> 
>>> 
>>> Here's my guess:
>>> 
>>> The typical use cases for asOrderedCollection and asArray are different. If you send asOrderedCollection you probably want to add more objects to it. If you send asArray you normally won't modify the result.
>>> 
>>> So in a way, you could see asOrderedCollection as the normal "safe" case which ensures the original is unmodified, and the asArray behavior as an optimization.
>> 
>> That sounds reasonable, I suppose.
>> 
>> Neither really fits how I use the SequenceableCollections, mind you.
>> I'd be happier with a purely functional implementation that quietly
>> shared (immutable) structure behind the scenes.
>> 
>> frank
>
>So optimizations aside, you are happier with the way asOrderedCollection works now, because it ensures the original collection is not affected?
>
>- Bert -
>
>
>
-----------------------------------------------------------
Louis LaBrunda
Keystone Software Corp.
SkypeMe callto://PhotonDemon
mailto:Lou at Keystone-Software.com http://www.Keystone-Software.com



More information about the Squeak-dev mailing list