different behavior between Dictionary and MethodDictionary for #add:

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

different behavior between Dictionary and MethodDictionary for #add:

cdelaunay
Hi,

I'm trying to test all subclasses of Dictionary and I just find a specific behavior for MethodDictionary :

-> #add:  return the association that has been added except for SmallDictionary for which #add: return the value of the association.

Is there a reason for such an implementaion?

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: different behavior between Dictionary and MethodDictionary for #add:

cdelaunay
Same problem with #removeKey:ifAbsent that doesn't return anything for MethodDictionary ( instead of the value of association removed).

2009/6/29 Cyrille Delaunay <[hidden email]>
Hi,

I'm trying to test all subclasses of Dictionary and I just find a specific behavior for MethodDictionary :

-> #add:  return the association that has been added except for SmallDictionary for which #add: return the value of the association.

Is there a reason for such an implementaion?


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: different behavior between Dictionary and MethodDictionary for #add:

cdelaunay


2009/6/29 Cyrille Delaunay <[hidden email]>
Same problem with #removeKey:ifAbsent that doesn't return anything for MethodDictionary ( instead of the value of association removed).

2009/6/29 Cyrille Delaunay <[hidden email]>

Hi,

I'm trying to test all subclasses of Dictionary and I just find a specific behavior for MethodDictionary :

-> #add:  return the association that has been added except for SmallDictionary for which #add: return the value of the association.
*this is for MethodDictionary and not SmallDictionary  

Is there a reason for such an implementaion?



_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: different behavior between Dictionary and MethodDictionary for #add:

Stéphane Ducasse
In reply to this post by cdelaunay
Hi cyrille



> Hi,
>
> I'm trying to test all subclasses of Dictionary

cool.


> and I just find a specific behavior for MethodDictionary :
>
> -> #add:  return the association that has been added except for  
> SmallDictionary for which #add: return the value of the association.

I do not know. Does anybody know?

> Is there a reason for such an implementaion?


probably lack of test reuse :)
this is a good example showing that reusing tests using traits is a  
good way to offer consistent
behavior.

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: different behavior between Dictionary and MethodDictionary for #add:

Lukas Renggli
>> -> #add:  return the association that has been added except for
>> SmallDictionary for which #add: return the value of the association.
>
> I do not know. Does anybody know?

SmallDictionary is an optimized dictionary originally written for the
refactoring browser. I does not use associations internally and thus
it would probably lose some of its performance returning an
association.

Maybe this is also a left-over because that code was originally
written on a different Smalltalk and inheriting from Dictionary seems
to be a bit dangerous in such a case anyway.

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project