Re: Polymorphic comparison

Xavier Leroy (xleroy@pauillac.inria.fr)
Wed, 19 Oct 1994 09:47:04 +0100 (MET)

From: Xavier Leroy <xleroy@pauillac.inria.fr>
Message-Id: <9410190847.AA23644@pauillac.inria.fr>
Subject: Re: Polymorphic comparison
To: John.Harrison@cl.cam.ac.uk (John Harrison)
Date: Wed, 19 Oct 1994 09:47:04 +0100 (MET)
In-Reply-To: <"swan.cl.cam.:256500:941018125425"@cl.cam.ac.uk> from "John Harrison" at Oct 18, 94 01:54:01 pm

Yes, I have been thinking for a while about generalizing the
generic equality function to a generic ordering function (with three
possible results: "equal", "less than", "greater than").

It's a simple extension of the code for generic equality (order base
types as usual and use a lexicographic extension for data structures)
--- no more of a hack than generic equality itself.

Usefulness: canonical representatives (as John Harrison mentioned),
ordered binary trees such as those implementing sets and maps (but the
problem remains to attach user-defined orderings to some types), and a
unified notation for comparisons over integers, floats, strings and
characters.

There are a few difficulties in the implementation that remain to iron out
(what to do with pointers outside the heap which may point to
well-formed objects, in which case a recursive descent is needed,
but may also point to foreign objects, in which case comparison should
fail), so I can't promise this will be in the next release, but I'll
give it a try.

- Xavier Leroy