If I asked this is that I could not. And I read the book on hash numbers.
I am sure you could have figured that by yourself,
I do not know where you see me offended and defensive. I asked because the wikipedia page was givingby thinking about how hash values are used and by looking at the code of kernel classes, instead of getting offended and turning all defensive.
I hope we can both learn from this episode. I do not enjoy antagonising people, but I will not write lengthy messages like this one every time someone questions my thinking.
Have a nice day.
Le 11/1/16 10:09, David Allouche a �crit :
Since it's not obvious why xor-ing is a bad way to produce hash, here is a link that gives some background
https://en.wikipedia.org/wiki/Hash_function#Uniformity
On 11 Jan 2016, at 10:01, David Allouche <david@allouche.net> wrote:
I happened to look at the new code for LayoutFrame>>#hash
hash
^self species hash bitXor:
(self leftFraction bitXor:
(self leftOffset bitXor:
(self topFraction bitXor:
(self topOffset bitXor:
(self rightFraction bitXor:
(self rightOffset bitXor:
(self bottomFraction bitXor:
self bottomOffset)))))))
This is a terrible, terrible way to compute a hash.
0 xor 0 = 1 xor 1 = 2 xor 2 = etc.
NEVER compute hashes with xor, that's wrong, and it causes horrible, hard to debug, performance bugs down the road.
SequenceableCollection>>#hash looks more like a correct way of doing it. I do not know what is the correct, efficient way to reuse this logic in�LayoutFrame>>#hash.
By the way, how do you guys do code reviews for code integrated into the core?