Hal Fulton wrote:

> I've been wondering something today...
> 
> Do people test equality of hashes very often? I, for one,
> do not.


Nor I, though I'm curious where one might want to do this, other than 
perhaps to see if two things are really the same thing.

> 
> For example, does anyone depend on these hashes being
> equal?
> 
>   x = {1=>2, 3=>4}
>   y = {3=>4, 1=>2}
>   x == y            #  => true
> 
> Or does anyone have code that depends in some other way
> on the fact that the ordering in a hash is NOT predictable?

Is there a reason that ordering should be unpredictable?  I'm wonder if, 
given a set of name/value pairs, using them to create a hash should 
always give the same ordering, as the hash should be following some 
specific algorithm to ensure, say, the fastest insertion/retrieval or 
some such thing.  Not that it just randomly decides how and where to 
store something.

So, your example may be plausible, unless it breaks some fundamental 
aspect of hashes.  (Though relying on a side effect of implementation 
might not be the best idea; for this to be useful, the language must 
assure that such behavior is part of the API.)


James