Vaguery / klapaucius

A clean, tested, maintainable Push interpreter written in Clojure.
MIT License
31 stars 2 forks source link

add a :comparator field to the PushType record #145

Open Vaguery opened 7 years ago

Vaguery commented 7 years ago

Several items (:char and :string) say they are comparable, but don't appear to actually be. I wrote custom comparator functions for those two types, when I wanted min and max, but there is a broader problem in that the custom comparators are not available outside the type definition namespaces.

Instead, consider adding a :comparator argument to the make-comparable function, which writes an explicit :comparator function into the record upon creation. This should be a formal compare equivalent, with all cases spelled out.

This can also be used to change between lexicographic and domination sorting in ordered collections, and could also provide a sort order for :set and :matrix as needed.