- make-default-comparatorprocedure
Returns a comparator known as a default comparator that accepts Scheme values and orders them in some implementation-defined way, subject to the following conditions:
- Given disjoint types a and b, one of three conditions must hold:
- All objects of type a compare less than all objects of type b.
- All objects of type a compare greater than all objects of type b.
- All objects of both type a and type b compare equal to each other. This is not permitted for any of the Scheme types mentioned below.
- The empty list must be ordered before all pairs.
- When comparing booleans, it must use the total order #f < #t.
- When comparing characters, it must use char=? and char<?. Note: In R5RS, this is an implementation-dependent order that is typically the same as Unicode codepoint order; in R6RS and R7RS, it is Unicode codepoint order.
- When comparing pairs, it must behave the same as a comparator returned by make-pair-comparator with default comparators as arguments.
- When comparing symbols, it must use an implementation-dependent total order. One possibility is to use the order obtained by applying symbol->string to the symbols and comparing them using the total order implied by string<?.
- When comparing bytevectors, it must behave the same as a comparator created by the expression (make-vector-comparator (make-comparator < = number-hash) bytevector? bytevector-length bytevector-u8-ref).
- When comparing numbers where either number is complex, since non-real numbers cannot be compared with <, the following least-surprising ordering is defined: If the real parts are < or >, so are the numbers; otherwise, the numbers are ordered by their imaginary parts. This can still produce somewhat surprising results if one real part is exact and the other is inexact.
- When comparing real numbers, it must use = and <.
- When comparing strings, it must use string=? and string<?. Note: In R5RS, this is lexicographic order on the implementation-dependent order defined by char<?; in R6RS it is lexicographic order on Unicode codepoint order; in R7RS it is an implementation-defined order.
- When comparing vectors, it must behave the same as a comparator returned by (make-vector-comparator (make-default-comparator) vector? vector-length vector-ref).
- When comparing members of types registered with comparator-register-default!, it must behave in the same way as the comparator registered using that function.
Default comparators use default-hash as their hash function.
- Given disjoint types a and b, one of three conditions must hold: