RFR 8009736: Comparator API cleanup

Per Bothner per at bothner.com
Wed Jun 12 17:23:26 UTC 2013


You might find interesting this proposal for "big" Scheme.
It views a "comparator" as a bundle consisting of an (optional)
comparator function, along with optional hash function,
equality function, and type-check function.

http://trac.sacrideo.us/wg/wiki/ComparatorsCowan

Using a more general "comparator bundle" can be
convenient at times.  For example when constructing
a hash table it is useful to pass the equality
function and the hash function as single object.
(Of course you normally don't use the compare
functions in those cases.)

If the ComparatorsCowan becomes part of Scheme,
I'd probably implement it as a class that implements
java.util.Comparator, at least for bundles that
have an actual compare function.
-- 
	--Per Bothner
per at bothner.com   http://per.bothner.com/



More information about the core-libs-dev mailing list