From: Robert Dober Date: 2006-08-21T19:26:10+09:00 Subject: Re: Why Does Hash Apparently Reorder Its Internal Representation And Other Associated Ponderings ------=_Part_37462_32692286.1156155968956 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: quoted-printable Content-Disposition: inline On 8/21/06, Yukihiro Matsumoto wrote: > > Hi, > > In message "Re: Why Does Hash Apparently Reorder Its Internal > Representation And Other Associated Ponderings" > on Mon, 21 Aug 2006 16:37:00 +0900, Hal Fulton < > hal9000@hypermetrics.com> writes: > > |Personally I favor introducing an ordered hash of some form into Ruby. > |Other people don't. Many want the original Hash kept as it is for speed > |(though I am still unconvinced that merely keeping a sequence number > |along with each key would impact speed dramatically). > > I am open to introduce order into 1.9 Hash, as long as we can > accomplish reasonable performance. I haven't yet read the "A use case > for an ordered hash" thread yet. I am facing a huge mountain of mails > after the vacation. > > matz. > > Honestly I would prefer a subclass and Mixins allowing to define the order of retrieval. As a matter of fact that is the only "order definition" that makes sense to me Now as it comes to implementation of course there must be a price to pay, either on ordered access or on storage. So I agree with the others who pointed out they are not willing to pay that price. Hash is for fast lookup after all. But having a subclass or a mixin for ordered hash access in the ruby core would be *great*!!! I am just dreaming: ohhhhhh =3D OrderedHash.new { |k1,k2| tell_my_friend_what_order_is(k1, k2) = } class MyOH < OrderedHash def key_order(k1, k2) ### Here we could define Mixins for common ke= y orders And would asking for having two like the following be too much? class FastOrderdHash (key order is stored in an AST e.g.) class SlimOrderedHash (keys are sorted on ordered access only) just my micromoney worth Cheers Robert --=20 Deux choses sont infinies : l'univers et la b=EAtise humaine ; en ce qui concerne l'univers, je n'en ai pas acquis la certitude absolue. - Albert Einstein ------=_Part_37462_32692286.1156155968956--