Dictionary>>#collect: should return a dictionary

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Dictionary>>#collect: should return a dictionary

Mathieu SUEN
Hi,

Looking at Dictionary>>#collect: I am wondering why it don't return a  
Dictionary.
So I give you the test and fix.

I didn't test the side effect.

HTH
        Math



Dictionary-collect.st (699 bytes) Download Attachment
DictionaryTest-testCollect.st (721 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Dictionary>>#collect: should return a dictionary

Klaus D. Witzel
Hi Math,

on Wed, 14 Feb 2007 21:48:21 +0100, you wrote:
> Hi,
>
> Looking at Dictionary>>#collect: I am wondering why it don't return a
> Dictionary.

This is so since SqueakV1.sources. In SmalltalkV2.sources (ST80) it  
returned a Bag. Both the latter and your variant are damned *slow*.

> So I give you the test and fix.

Have you considered all the packages which perhaps depend on the current,  
speedy implementation?

/Klaus

> I didn't test the side effect.
>
> HTH
> Math



Reply | Threaded
Open this post in threaded view
|

RE: Dictionary>>#collect: should return a dictionary

Alan L. Lovejoy
In reply to this post by Mathieu SUEN
<Mathieu Suen>
Looking at Dictionary>>#collect: I am wondering why it don't return a
Dictionary.
</Mathieu Suen>

The ANSI Smalltalk Standard requires that Dictionary>>collect: answer a new
Dictionary with the same keys, but whose values have been transformed by the
transformer (the argument of the message.)

--Alan



Reply | Threaded
Open this post in threaded view
|

Re: Dictionary>>#collect: should return a dictionary

Mathieu SUEN
In reply to this post by Klaus D. Witzel
Yes of course so how to get the same behavior? provide a new  method  
in Dictionary?

        Math

On Feb 14, 2007, at 10:17 PM, Klaus D. Witzel wrote:

> Hi Math,
>
> on Wed, 14 Feb 2007 21:48:21 +0100, you wrote:
>> Hi,
>>
>> Looking at Dictionary>>#collect: I am wondering why it don't return a
>> Dictionary.
>
> This is so since SqueakV1.sources. In SmalltalkV2.sources (ST80) it  
> returned a Bag. Both the latter and your variant are damned *slow*.
>
>> So I give you the test and fix.
>
> Have you considered all the packages which perhaps depend on the  
> current, speedy implementation?
>
> /Klaus
>
>> I didn't test the side effect.
>>
>> HTH
>> Math
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: Dictionary>>#collect: should return a dictionary

Klaus D. Witzel
Hi Math,

on Wed, 14 Feb 2007 22:41:53 +0100, you wrote:

> Yes of course so how to get the same behavior? provide a new  method in  
> Dictionary?

If it where easy (with regards to existing, most likely unloaded packages)  
I would have made a suggestion.

Perhaps you add it under #dictionaryCollect: so that people can use it if  
wanted.

I agree with Alan about ANSII but, this is not compatible with the  
received Squeak releases.

Furthermore, there is a discrepancy between Dictionary>>#select: and  
Dictionary>>#collect: :(

/Klaus

> Math
>
> On Feb 14, 2007, at 10:17 PM, Klaus D. Witzel wrote:
>
>> Hi Math,
>>
>> on Wed, 14 Feb 2007 21:48:21 +0100, you wrote:
>>> Hi,
>>>
>>> Looking at Dictionary>>#collect: I am wondering why it don't return a
>>> Dictionary.
>>
>> This is so since SqueakV1.sources. In SmalltalkV2.sources (ST80) it  
>> returned a Bag. Both the latter and your variant are damned *slow*.
>>
>>> So I give you the test and fix.
>>
>> Have you considered all the packages which perhaps depend on the  
>> current, speedy implementation?
>>
>> /Klaus
>>
>>> I didn't test the side effect.
>>>
>>> HTH
>>> Math
>>
>>
>>
>
>
>



Reply | Threaded
Open this post in threaded view
|

Re: Dictionary>>#collect: should return a dictionary

Philippe Marschall
In reply to this post by Mathieu SUEN
2007/2/14, Alan Lovejoy <[hidden email]>:
> <Mathieu Suen>
> Looking at Dictionary>>#collect: I am wondering why it don't return a
> Dictionary.
> </Mathieu Suen>
>
> The ANSI Smalltalk Standard requires that Dictionary>>collect: answer a new
> Dictionary with the same keys, but whose values have been transformed by the
> transformer (the argument of the message.)

GST does so. STX returns a Bag of the values transformed, VW returns
an OrderedCollection of the values transformed.

Philippe

> --Alan
>
>
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Dictionary>>#collect: should return a dictionary

Klaus D. Witzel
On Wed, 14 Feb 2007 22:57:01 +0100, Philippe Marschall wrote:

> 2007/2/14, Alan Lovejoy <[hidden email]>:
>> <Mathieu Suen>
>> Looking at Dictionary>>#collect: I am wondering why it don't return a
>> Dictionary.
>> </Mathieu Suen>
>>
>> The ANSI Smalltalk Standard requires that Dictionary>>collect: answer a  
>> new
>> Dictionary with the same keys, but whose values have been transformed  
>> by the
>> transformer (the argument of the message.)
>
> GST does so. STX returns a Bag of the values transformed, VW returns
> an OrderedCollection of the values transformed.

ROTFL :) Long live language compatibility :)

So perhaps, VW ported code might break if Squeak adopted ANSI.

> Philippe
>
>> --Alan
>>
>>
>>
>>
>
>