mirror of
https://github.com/enso-org/enso.git
synced 2024-11-22 22:10:15 +03:00
1f8511dab2
Add `Comparator` type class emulation for all types. Migrate all the types in stdlib to this new `Comparator` API. The main documentation is in `Ordering.enso`. Fixes these pivotals: - https://www.pivotaltracker.com/story/show/183945328 - https://www.pivotaltracker.com/story/show/183958734 - https://www.pivotaltracker.com/story/show/184380208 # Important Notes - The new Comparator API forces users to specify both `equals` and `hash` methods on their custom comparators. - All the `compare_to` overrides were replaced by definition of a custom _ordered_ comparator. - All the call sites of `x.compare_to y` method were replaced with `Ordering.compare x y`. - `Ordering.compare` is essentially a shortcut for `Comparable.from x . compare x y`. - The default comparator for `Any` is `Default_Unordered_Comparator`, which just forwards to the builtin `EqualsNode` and `HashCodeNode` nodes. - For `x`, one can get its hash with `Comparable.from x . hash x`. - This makes `hash` as _hidden_ as possible. There are no other public methods to get a hash code of an object. - Comparing `x` and `y` can be done either by `Ordering.compare x y` or `Comparable.from x . compare x y` instead of `x.compare_to y`. |
||
---|---|---|
.. | ||
Benchmarks | ||
Examples_Tests | ||
Geo_Tests | ||
Google_Api_Test | ||
Image_Tests | ||
Meta_Test_Suite_Tests | ||
micro-distribution | ||
Table_Tests | ||
Tests | ||
Visualization_Tests |