Am Di., 25. Mai 2021 um 17:38 Uhr schrieb Sandra Snan <xxxxxx@idiomdrottning.org>:
In SRFI-128, make it so that (=? "hi" "hi") works without having
to supply the default comparator as the first arg. That's why
there is a default and why you can register new defaults.

I know that (=? (make-default-comparator) "hi" "hi") works.
That's the problem, that it can't figure that out on its own.

This is already a variadic procedure.
(Since you can do (>? "hi" "hi" "hi").)

I mean ideally I would've not had that first argument in the first place, I'd just have (proc arg arg arg arg...) Instead of (proc comp arg arg arg) being an option.

So either for backwards compatibility dispatch using (comparator?) on
first arg (then if people wanna compare comparators, they can do it with
(>? comp comp comp) for example) or change the interface so that it does
not need that second argument but instead looks up the default.

Since people can register new default comparators, temporarily or
permanently.

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.
 


PS also here is a reason for the above:


 
It is a shame that these short and elegant names were clobbered.

(=? (here-is-how-i-get-to-a-useful-comparator) "hi" "hi")

is almost as cumbersome as  (string=?  "hi" "hi")

Have you made some experiments about which Scheme implementations are able to optimize the former into the latter? If Scheme implementations are generally not capable of doing this conversation, one shouldn't use the generic comparison operator when the types of the arguments (like "hi" in your example) are determined a priori.

Moreover, string=? is type-safe in that it should raise an error if the arguments are unexpectedly not strings. So from safety aspects, always use string=? when you have string arguments. The generic procedures are just for, well, generic algorithms.