On Tue, May 25, 2021 at 11:55 AM Marc Nieper-Wißkirchen <xxxxxx@nieper-wisskirchen.de> wrote:

The comparator registry imports a number of problems. Contrary to the static library system, registration is dynamic and the default comparator may at any time be overwritten by other code. I would suggest not to rely on this mechanism if possible.

It's true that the mechanism makes it possible to shoot yourself in the foot by registering comparators with non-disjoint predicates (which is explicitly an error per SRFI 128).  It is also possible to shoot yourself in the foot by altering the source of a system-supplied library.  I don't know what to do about that one except to modify `import` to specify a hash of the contents of the library to be imported.

In German, I would say that "der Vergleich hinkt und zwar gewaltig" (meaning that the comparison is misleading but using metaphorical language; is there an equivalent idiom in English?).

It's about encapsulation. No one would say that encapsulation of libraries is useless because one can always look into or change the source of such libraries. Scheme's means to enforce encapsulation is lexical scoping and the static library system (and macro hygiene). Even Scheme's dynamic bindings (parameters) follow this principle because they are implemented through lexical references.

What breaks encapsulation is shared global state. The comparator registry is such shared global state. Sometimes it's not possible to avoid global shared state, and I don't have a better proposal for SRFI 128's global registry yet (apart from adding a new clause to each record-type definition that specifies the default comparator).

All I am saying is that don't use global state if you don't have to. In the original post in this thread, we haven't seen a compelling reason to use the default comparator and I dare to claim that there aren't many.

Registering comparators for non-disjoint predicates can happen coincidentally when one library registers a comparator for a full hierarchy of record types while another library just registers a comparator for a single record in this hierarchy (which is not very far-fetched). On the other hand, altering the source of a system-applied library doesn't happen coincidentally.