Equality and hash made easy

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

Equality and hash made easy

Noury Bouraqadi-2
Hi,

I proposed in early february an enhancement to avoid having redefine hash and = together and I would like to see it integrated in 1.3.  
My idea is that the implicit link between these two methods should be supported by the system.

A first solution is proposed on the issue tracker
http://code.google.com/p/pharo/issues/detail?id=3657

To make instances of some class comparable, simply make the class use the TEquality trait.

TEquality relies on message valuesToCompareForEquality sent to objects for both = and hash.
The default implmentation of this message is provided by Object.
Override ONLY valuesToCompareForEquality method for custom equality check.


Noury
http://car.mines-douai.fr/noury
--
-6th National Conference on
“Control Architecture of Robots”
24-25 may 2011, Grenoble area, France
http://car2011.inrialpes.fr/

-19th ESUG International Smalltalk Conference
22-26 August 2011, Edinburgh, UK
http://www.esug.org/Conferences/2011

-19èmes Journées Francophones sur les Systèmes Multi-Agents (JFSMA’11)
http://www.univ-valenciennes.fr/congres/jfsma2011/
17-19 Octobre 2011, Valenciennes, France