[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Naming, compare function return values



Panu A Kalliokoski wrote:

(2) the codomain of compare functions is {-1, 0, 1} which reminds me of
other (bad) programming languages where real enumerations are hard to
do.  While these values bear some intuitive semblance to orderings
(because of the sign function), the traditional Lisp/Prolog/ML way for
things like this are real descriptive values, in the case of Scheme, the
symbols {less, equal, greater} (or {lt, eq, gt}).  The only reason to
use the nondescriptive values is AFAIU the possibility to add and
multiply values produced from compare functions, which easily leads to
ugly code.  So, is there some kind of rationale for the codomain of
compare functions?

See the section "How to represent the three cases?" in the
Design Rationale:

    <http://srfi.schemers.org/srfi-67/srfi-67.html#node_sec_6>

--
Jens Axel Søgaard