-
Notifications
You must be signed in to change notification settings - Fork 790
Comparators
Fogus edited this page Jan 9, 2013
·
3 revisions
TODO
- comparison fn: boolean valued fn
- comparator: -/0/+ valued fn
- comp: either of the above
(These terms are not good, but I wanted one-word ways to talk about each idea below.)
- different underlying platform API
- Java expects comparators (instances of Comparator)
- goog expects comparison fns
- users care about composability, not abstractions
- Clojure fns can be either comparators or comparison fns
- implementation via wrapper in AFn's Comparable implementation
- newly created fns just work
- protocols not helpful for implementation
- if fns were some kind of IComparable, would just have to convert back to plain fns for goog to use them
- don't see any obvious performance win
- protocols not helpful for consumers
- making comp writers implement a protocol is just introducing a Javaism
- usage
- no Comparable protocol
- just use fns
- implementation
- do AFn's wrapping work in a helper fn that wraps user fns inside sort
I am pretty confident about the usage. Less confident about implementation, but this can be improved later.
- Rationale
- Quick Start
- Differences from Clojure
- [Usage of Google Closure](Google Closure)