From: Clifford Heath Date: 2011-04-13T15:35:30+09:00 Subject: Re: Hash Surprises with Fixnum, #hash, and #eql? On 04/13/11 15:51, Charles Oliver Nutter wrote: > On Tue, Apr 12, 2011 at 9:05 PM, Clifford Heath wrote: >> On the contrary, I could live with it being either way. >> The different interpreters do it both ways, or not at all. >> That is the fact. That you've missed it makes me think you >> *still* haven't actually run my code on the three interpreters >> I mentioned. if that's true, it just underscores my suspicion >> that you're engaging in defensive sophistry rather than rational >> argument. > > Perhaps I'm missing something. Should I be seeing different results than this? > > https://gist.github.com/917031 That result is reasonable, using MRI. Interesting, and nice, that it figures out it doesn't need to call Fixnum#hash to be able to choose a bucket. (BTW, that *uncommon* case means there's a test and branch which is superfluous and excessively costly for the more common case, according to arguments you've made against detecting monkey patching) If you do the same thing with JRuby however, the first test contains this: Looking up using Integer: nil I.e. using Integer, JRuby doesn't call Fixnum#eql? the way MRI does. Do it again using Rubinius, and you get this: Looking up using Integer: .hash => 47 nil I.e. Rubinius calls Fixnum#hash, but not Fixnum#eql? So both non-MRI interpreters fail, and in different ways. Clifford Heath.