cnuernber / dtype-next

A Clojure library designed to aid in the implementation of high performance algorithms and systems.
Other
319 stars 18 forks source link

Unexpected behaviour when comparing certain numeric types #99

Closed kiramclean closed 1 month ago

kiramclean commented 1 month ago

tech.v3.datatype.functional unexpectedly throws a ClassCastException when comparing certain numeric types (e.g. doubles and longs, as in (tech.v3.datatype.functional/> 3.0 2)) instead of performing the comparison as expected. Most users would typically expect numeric types to "just work" together without any issues.

The root cause appears to be that the library is delegating to Java's Comparable interface for performing certain comparisons, which does not allow for mixing different numeric types like floats/doubles and longs. This is in contrast to Clojure's built-in numeric comparison functions, which handle these kinds of mixed numeric types without issue.

In the discussion in this thread it was confirmed that object pathways are supposed to delegate to Clojure, and some suggested solutions were proposed, including: