From: Stefan Lang Date: 2009-02-14T02:15:40+09:00 Subject: Re: If you are unhappy with the direction of Ruby 1.8.7+, respond 2009/2/13 James Coglan : >> >> > Regardless of whether they're *supposed* to, the Rubies I've used before >> > 1.8.7 actually do iterate in insertion order. >> >> NO THEY DO NOT. It is the nature of a regular hashtable that >> the order of entries in its internal data structures depends >> only on the hash function and its inputs. It doesn't know >> anything about the order of entries in your hash literal. >> >> I've shown you examples using Ruby *1.8.6* that clearly >> demonstrate that it gives a **** about order of appearance >> in a literal, or insertion order. > > > > I'm really not up for a slanging match so let me just say that, in code I've > written, Ruby < 1.8.7 has demonstrated the behaviour I described. This may > be a fluke or a bug, in which case I will investigate further and file bugs > if necessary. I can tell you how such a bug report would look like: Bug: In Ruby 1.8.x Hash iteration order ..... Rejected: Hash iteration order in 1.8 is undefined. > What I do know is that I've had code in a library released > over 2 years ago and used by a fair number of people relying on this > behaviour and heard no complaints until 1.8.7 arrived. A hidden bug in your code because of an incorrect assumption. > I realise that > hashtables are not ordered in 1.8 and have since made my code more robust. > I'm not questioning your examples -- ... You seem to be ignoring them. > ... you can but experiment to see what > works -- and I will try to extract the code from my project that > demonstrates my point when I have some time. > > I'm not the least bit interested in who's right or wrong or in berating the > Ruby code devs or indeed anyone else, and was hoping for a productive > discussion, not people repeatedly asserting that I don't know how a hash > table works and trying to shut me up. When I've time I'll see if what I have > is a Ruby bug or something else. Until then I'm canning this conversation. I and others here took the trouble finding out and explaining why your code failed. That's a productive discussion. You'd just have to accept that it's your code that was buggy. There's nothing bad about that. Everybody writes buggy code sometimes. Instead you keep looking for a bug in Ruby that doesn't exist, as has been clearly proven. Stefan