Documenting the `comparator-register-default!` procedure John Cowan (16 Nov 2014 17:49 UTC)
Re: Documenting the `comparator-register-default!` procedure Kevin Wortman (17 Nov 2014 20:01 UTC)

Documenting the `comparator-register-default!` procedure John Cowan 16 Nov 2014 17:49 UTC

The new sample implementation of comparators exports an additional
procedure that is deliberately not provided in the SRFI, called
`comparator-register-default!`.  This is intended for other sample
implementations to register their comparator objects so that they will
be correctly used by the default comparator.  Because the whole idea
of registering comparators depends on the particulars of the sample
implementation, it is not portable to other implementations of comparators.

When `comparator-register-default!` is invoked with a single argument,
a comparator, the default comparator is extended to understand objects
that satisfy the type test of the registered comparator, and to apply it
when comparing two objects that satisfy that type test.  Such objects
are said to belong to "registered types", whereas all other objects
other than the built-in R7RS-small types belong to "unregistered types".
When dealing with objects of unregistered types, the default comparator
makes them compare equal and hash to 0, a safe but fairly useless default.

The effect of comparing two objects of different registered types
is only partly predictable, as it depends on the order in which
`comparator-register-default!` is called.  However, the normal guarantees
of the default comparator still apply.  In addition, Every object of a
registered type compares less than all objects of unregistered types.

--
John Cowan          http://www.ccil.org/~cowan        xxxxxx@ccil.org
A few times, I did some exuberant stomping about, like a hippo auditioning
for Riverdance, though I stopped when I thought I heard something at
the far side of the room falling over in rhythm with my feet.  --Joseph Zitt