Re: [Scheme-reports] R7RS-large comparators Noah Lavine (16 Jul 2013 03:23 UTC)
Re: [Scheme-reports] R7RS-large comparators Alexey Radul (16 Jul 2013 04:21 UTC)
Re: [Scheme-reports] R7RS-large comparators Marijn (16 Jul 2013 07:20 UTC)
Re: [Scheme-reports] R7RS-large comparators Ray Dillinger (16 Jul 2013 07:52 UTC)
Re: [Scheme-reports] R7RS-large comparators John Cowan (16 Jul 2013 06:09 UTC)

Re: [Scheme-reports] R7RS-large comparators Alexey Radul 16 Jul 2013 04:21 UTC

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.

On Mon, Jul 15, 2013 at 11:22 PM, Noah Lavine <noah.b.lavine@gmail.com> wrote:
> This is an excellent point. I would just like to add that it also makes it
> trivial to extend the comparator interface to partial orders - they could
> return 'not-comparable if their arguments couldn't be ordered.
>
> Best,
> Noah Lavine
>
>
> On Mon, Jul 15, 2013 at 7:28 PM, Kevin Wortman <kwortman@gmail.com> wrote:
>>
>> On 07/12/2013 08:51 AM, John Cowan wrote:
>> > Ray Dillinger scripsit:
>> >
>> >> On floating point numbers it would make sense (to me anyway) to return
>> >> -0.0
>> >> in the case of a comparison of +0 and -0, and return NaN in the case of
>> >> any
>> >> comparison involving NaNs.
>> >
>> > In this context, that would mean returning one of five values:
>> >
>> > return 1 when A > B
>> >
>> > return 0 when A = B, unless one is 0.0 and the other is -0.0
>> >
>> > return -0.0 when one is 0.0 and the other is -0.0
>> >
>> > return -1 when A < B
>> >
>> > return +nan.0 when A is NaN or B is NaN
>> >
>> > This seems extremely irregular.
>> >
>>
>> I think that a comparator returns one of three conceptual results:
>> less-than, equal, or greater-than. There is a long history of using the
>> integer values -1, 0, and +1 to represent those concepts. However these
>> concepts are not really integers, and using integers to represent them
>> may be a red herring. I think Haskell gets this right by yielding one of
>> the algebraic constructors LT, EQ, or GT (
>>
>> http://www.haskell.org/ghc/docs/latest/html/libraries/base/Prelude.html#t:Ordering
>> ).
>>
>> Perhaps Scheme comparators should return one of the symbols 'less 'equal
>> or 'greater ? Or perhaps we should standardize enumerated types first
>> and then have comparators return an enum object.
>>
>> Kevin Wortman
>>
>>
>>
>> _______________________________________________
>> Scheme-reports mailing list
>> Scheme-reports@scheme-reports.org
>> http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
>>
>
>
> _______________________________________________
> Scheme-reports mailing list
> Scheme-reports@scheme-reports.org
> http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports
>

_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports