[m-dev.] Inequalities and compare/3

Fergus Henderson fjh at cs.mu.OZ.AU
Fri Feb 2 00:40:25 AEDT 2001


On 31-Jan-2001, Ralph Becket <rbeck at microsoft.com> wrote:
> I observed with the array__sort implementation that the standard
> inequalities <, =<, >, >= are not defined on arbitrary types;
> instead one has to use compare/3.
> 
> Is that a deliberate design decision?

No, just historical stuff inherited from Prolog.

> If not, would it be sensible
> to make X < Y a synonym for compare((<), X, Y) etc. for whatever
> type X and Y share?

Yes, modulo concerns about backwards compatibility
(for the V1 library; the V2 library is a different story).

> On that note, the reference manual makes no reference to the
> standard ordering, but the comment for compare/3 in builtin.m
> does.  Personally I'd be happier to have some statement on the
> subject so I know when I can rely on, say, sorting an assoc_list
> to do the "obvious" thing.

Well, there's nothing in the *language* which depends on any standard
ordering; it's just the *library* that cares.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list