On to Hydro

Mark S. Miller markm@caplet.com
Thu, 17 Aug 2000 10:15:11 -0700


At 04:49 AM 8/17/00 , Tyler Close wrote:
>I object. ;) I think you mean the 2.0 version of Hydro. 2.0 is the one
>that has the immutable containers. The 1.0 version uses mutable
>containers.

My mistake.  I navigated from the waterken.com page rather than looking at 
the original email.

>This is not a style conflict, it's a bug. I've corrected it ...
>
>public static
>boolean compare(Double a, Double b)
>{
>     return a.doubleValue() > b.doubleValue() || (a.isNaN() &&
>!b.isNaN());
>}
>
>I specified total ordering because I think most programmers are not
>prepared to deal with the subtleties between equivalence and equality.
>One example of this is a SortedSet of doubles with NaN. If two sets
>contain the same elements, you'd expect them to be equal, but they may
>not be, depending on when the NaN was inserted. This is just too
>surprising.

At 06:35 AM 8/17/00 , Tyler Close wrote:
>I don't think we can use strict subset on sets as an ordering for a
>container. 

Having NaNs be larger than all non-NaNs, including positive infinity, is 
surprising too.  NaNs, however, are an edge condition.  Subsets, subtypes, 
preferences, causality -- the universe is rife with partial orderings, and 
partial orderings are the more general category.

However, I think we may be asking two separable questions. It seems you are 
asking "What ordering predicate do we require so we may sort?", whereas I'm 
asking "What should it mean when the programmer writes 'a < b'?". I'm sure 
we both agree it would be wonderful to have the same answer to both 
questions, but let's start by asking both questions.

To answer your question, I admit the sort algorithm built into E's existing 
container library does assume a StrictWeakOrdering (thanks for the 
definitions page), which is a much stronger contract than a partial 
ordering.  However, this library does default to using "<" among the 
elements as the ordering predicate, even though "<" means only 
PartialOrdering in general.  So, yes, you've identified another design 
error in the existing libraries.  (Perhaps comparing two systems is faster 
way to identify bugs in both than examining them each individually?)

Btw, we have here a great example for the previous discussion: 
StrictWeakOrdering is a stronger contract, and therefore a subtype of, 
PartialOrdering. However, it provides no greater authority, and so having 
both violates no security principles.  This isn't to say that having both is 
desirable.


         Cheers,
         --MarkM