[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] R7RS-large comparators
On Tue, Jul 16, 2013 at 3:19 AM, Marijn <hkBst@x> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 16-07-13 06:21, Alexey Radul wrote:
>> In addition to the weight of tradition, -1, 0, and 1 have the
>> benefit of being naturally correctly totally-ordered amongst
>> themselves. Semantically chosen symbols are unlikely to share this
>> advantage.
>
> What exactly is ``naturally correct'' about this inherited total
> ordering?
Precisely that any currying of (the second argument of) any compare
procedure becomes a homomorphism of totally ordered sets.
> Do you also think (< (< 0 1) (< 1 0)) should be #t or #f?
That example is irrelevant, but
(let ((<=> (comparator-compare-procedure integer-comparator)))
(< (<=> -2 0) (<=> 2 0)))
absolutely should return #t.
> If we could compare functions for equality, we could have the return
> values be the respective equivalents of <, > and =. Failing that maybe
> '<, '> and '= would be appropriate?
I like Haskell's choice of a new, disjoint type for the answers of
compare. In Scheme, however, such a thing adds considerable extra
weight, so I am not even sure I would support it. In addition to
being traditional (and therefore quite recognizable), integers have
the (debatable) advantage over symbols of allowing comparator puns,
such as
(define (abs x)
; Look Ma, no branch!
(* x ((comparator-compare-procedure real-comparator) 0)))
which may even be important numerical computations. However, of all
the symbol proposals so far, I like '< '= and '> best, because of
this:
> (symbol<? '< '=)
;Value: #t
> (symbol<? '= '>)
;Value: #t
~Alexey
_______________________________________________
Scheme-reports mailing list
Scheme-reports@x
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports