Hi, thank you all for your answers. Cédrick Béler wrote:
But it raises the question if : (1 to:4)hash = #(1 2 3 4)hash should return true instead ?? principally yes, but it would slow down the Interval>>hash implementation considerably. id guess one would first make SequentialCollection>>hash a bit faster & shorter or one could very fast get a memory overflow. i mean the trick with Intervals is not so much (1to:4), but (-100000000000 to: 100000000000) which doesnt use any space and time.
jgfoster wrote:
In GemStone the objects are not equivalent (Iâm not arguing that this is right, just that it avoids the problem you identify). i see, yes, it can happen that hash has its own idea what equivalence _really means.
I wonder what would happen if the hash comparison were added to the equivalence operator (#â=â)! you probably mean something like this: #= ^(doWhatYouveDoneBefore)and:[self hash = object hash] of course that would eliminate the problem but it would need to be implemented everywhere. if not, #= could become not symmetric which produces the same problems (actually i stumbled upon this question because i implemented #= for a subobject of Array and gave it the species Array, problematic because with my implementation it opened the possibility of myObject~=anArray but anArray=myObject). actually #= in pharo is symmetric (and transitive, which also is necessary for hash to work) because it is more or less carefully designed , the symmetry is not somehow automatically incorporated in the language, and as i noticed its not too difficult to break that symmetry with ones own objects <stupid grin>
On 07/30/2018 05:27 PM, Henrik Sperre Johansen wrote:
+1, this is a bug. Either Interval >> #hash needs to change*, or the equivalency be broken**.
Fun fact: #(1 2 3 4) = #[1 2 3 4] false You'd think they might be more similar than an Interval and an Array, or a LinkedList containing ValueLinks and an Interval, but no ;) <g> i guess it is difficult to juggle & balance everything between all the different kinds of collections.
thanks again folks werner