A new comparator srfi, srfi:128, was finalized a couple of weeks ago. It is a rewrite of srfi:114, with simpler interface that appears to work with other parts of Scheme better (e.g. the comparison procedure of srfi-114, which returns -1, 0 or 1, doesn't seem Scheme-y, even though such interface is seen in other languages.)
I like srfi-128 better and I would've adopted it natively if Gauche hadn't already adopted srfi-114. At this moment, however, srfi-114 comparator is built-in and tightly coupled with Gauche's native datatypes such as built-in treemaps. Also, Gauche's internal compare API has been returning -1/0/1 scheme, so it goes better with srfi-114.
On the other hand, we expect future portable libraries will use srfi-128, and we want to encourage Gauche libraries to do so. We don't want to penalize code using srfi-128 with the overhead of adaptation layer.
So we chose to support both srfi-114 and srfi-128 natively.
Srfi-114 comparator can emulate srfi-128's, and vice versa.
Speed-sensitive internal code checks which flavor the passed
comparator is, and uses optimized path. Most Scheme-level code
would use high-level utilities such as
anyway, which hides the difference under the hood.
The only conflict in two srfis is the constructor,
make-comparator. We already extended srfi-114
make-comparator to take the optional name argument,
so it'll be tricky to distinguish two flavors with extra
arguments. Besides, we do want to encourage new code to
use srfi-128; so we decided to break the backward compatibility.
make-comparator will be an extension of srfi-128, with
optional name argument. We provide srfi-114 comparator
under a different name
(The name could be confusing, but it reflects the
generic function which is compatible to srfi-114's comparison
procedure.) If you import srfi-114, it imports
shadows the built-in one.
Gauche have supported subset of srfi-114 as built-in. Some of them are the same in srfi-128, some have different names, and some are newly introduced in srfi-128. Here's the correspondence.
- *1 Provided as
- *2 If srfi-128 comparator is given, returns a synthesized procedure that uses equality and ordering predicates.
- *3 If srfi-114 comparator is given, returns a synthesized procedure that uses comparison procedure.
- *4 If srfi-128 comparator is given, use its equality and ordering predicates.
- *5 Same as Gauche's
The change is currently undergone. We expect this to be the last major change before releasing 0.9.5.