From: Hal Fulton Date: 2004-09-06T08:41:25+09:00 Subject: Re: Hashes and ordering Markus wrote: > Here's a stab at an instance of case #1, the simplest way I could come > up with to model the semantics I think you are looking for (note: this > is _not_ claimed to be the best way to implement the semantics, just the > clearest way to express them): [snip code] Yes, I have implemented things similar to this before. The one remaining problem for me was always a convenient syntax for literals. (It may not be so important to most people, but it is to me.) > This setup gives the following answers to the questions I'd asked > previously (properly translated of course): > > p _(1=>2)+_(3=>4) # _(1=>2)+_(3=>4) > > p _(1=>2)+_(3=>4)+_(1=>5) # _(3=>4)+_(1=>5) [snip rest of examples] Your underscore notation is clever, but compared to traditional hash notation it still hurts my eyes (and my fingers). As for semantics, I think you have captured my intent, although I may have missed one or two items. I will certainly save this for my notes also. However, Matz's latest reply indicates to me that if order is added to the Hash class, then even literals will be ordered. I had thought that ordered literals would imply that {a=>b,c=>d} != {c=>d,a=>b} but I see now that is not the case. Thanks, Hal