From: Fergal J Byrne Date: 2006-08-22T03:54:39+09:00 Subject: Re: A use case for an ordered hash -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Rick DeNatale wrote: > On 8/21/06, Bil Kleb wrote: >> Phillip Hutchings wrote: >> > Using an ordered hash for one >> > person's benefit would kill the speed and jack up memory usage. >> > >> > [..] but replacing the Hash is not the way to go. >> >> I don't think anyone is suggesting replacing the >> existing Hash. As I see it, the ordered hash would >> merely be an alternative to the standard hash. > > Which, as has been shown can be provided without changes to the base > specification/implementation of Ruby. > > The fly in the ointment, is that a few of the proponents of > OrderedHash seem to strongly require a literal syntax for the beast. > That's the one thing which seems to require divine intervention . This functionality is not part of Hash as traditionally understood, including those new to Ruby. Adding it to the core Hash in the language will add a space and time cost to all programs currently using Hash. If you need a hash with this functionality, create a mixin module containing the extra code (several examples have appeared in these threads) and include it where you need it. I often have a hankering for this kind of functionality in random access data structures (database tables more than in-memory structures), so I can see the use of it. Doesn't strike me as a must-have addition (or subtraction) for the core Hash class... And I wouldn't call it an OrderedHash (suggests sorting by the data rather than by insertion order). Call the mixin something like InsertionOrderMemory and you could conceivably use it for other structures... - -- regards fergal byrne technical director Adnet Web Development - Building for Business since 1995 http://www.adnet.ie/ t:+353 1 676 4262 aim/skype:FergByrne -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.3 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFE6gFqd3SE35LsMPcRAlnwAJwN7FcUim+5ljQ+fliYBc3HVii7RgCghVNO hveor+GT98zkVDHTW9FNuYc= =b63O -----END PGP SIGNATURE-----