English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
[Caml-list] Sorting
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2001-11-05 (12:26)
From: jeanmarc.eber@l...
Subject: Re: [Caml-list] Sorting
En réponse à Xavier Leroy <xavier.leroy@inria.fr>:

> > What are advantages and disadvantages in parametrizing either by '<'
> > or by the 3-way comparison?
> In addition to what has been said already, the 3-way comparison is
> less error-prone with respect to two classic errors:
> 1- passing a "less than or equal" predicate where a "less than"
>    predicate is expected, or conversely;
> 2- passing a predicate that is not a total ordering where a total
>    ordering is expected.
> Both errors could cause the old Sort.array or Sort.list functions to
> misbehave seriously.  These errors are still possible with the 3-way
> comparison approach, but less likely I think.
> - Xavier Leroy

When we are just about "sorting predicates":

I always have a little hesitation about the properties that are
assumed on this functions.

Shouldn't one say clearly in the OCaml doc that these comparison
function are simply suppposed (if I'm not wrong) to be a

  total pre-order, that is a binary predicate that is

  total (of course)

BUT NOT necessarly anti-symetric.

Of course, these properties have to be "translated" back into the
3-way comparison approach (thats trivial) but I would find it helpful to
say precisely what properties these functions should have.

Jean-Marc Eber
LexiFi Technologies
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr