From: "David A. Black" Date: 2009-02-13T10:12:08+09:00 Subject: Re: Hash order (was: Re: If you are unhappy with the direction of Ruby 1.8.7+, respond) Hi -- On Fri, 13 Feb 2009, James Coglan wrote: > 2009/2/12 David A. Black > >> Hi -- >> >> On Fri, 13 Feb 2009, James Coglan wrote: >> >> >>>> >>>> >>>> What do you mean with "Hash ordering"? >>>> An order for Hash instances? Hash doesn't define a <=> method. >>>> Or iteration order of Hash elements? That wasn't defined >>>> in 1.8.6 (I don't know if it is in 1.8.7). >>>> >>> >>> >>> >>> In 1.8.6, iteration order would be the same as the order that the keys >>> appear in the source. To work with 1.8.7, you need to create an empty hash >>> and add keys one by one rather than putting them all in a hash literal >>> (see >>> the patch). >>> >> >> Hashes aren't ordered at all in 1.8, as far as I know. > > > > I realise that there is no explicit iteration order specified for hashes in > 1.8. All I know is that this patch fixed by 1.8.7 bugs: Sorry, I misunderstood what you were getting at. > http://github.com/jcoglan/packr/commit/9ece59428bbd1bfd497b45a2ae4de2d163a24849 > > Basically involves inserting keys in an explicit order rather than using > hash literals. This project uses a bunch of custom collection classes but > they're basically wrappers for arrays and hashes that merge array and hash > functionality into a single class. The constructors would iterate over the > hashes provided and insert values, and this insertion order changed in > 1.8.7. > > I would concede that this is something of a grey area as it's neither a bug > fix or an explicit feature addition, but the question was asked about 1.8.6 > code that broke, and this is an example. I still have a regex-related bug in > this project that I've been unable to fix under 1.8.7. In fact, if anyone is > able to fix the last remaining test failure I'd be incredibly grateful. I can't get any of your tests to fail under 1.8.7, at least the one I've got installed on the machine where I tried it (pl0). David -- David A. Black / Ruby Power and Light, LLC Ruby/Rails consulting & training: http://www.rubypal.com Coming in 2009: The Well-Grounded Rubyist (http://manning.com/black2) http://www.wishsight.com => Independent, social wishlist management!