Is there support for BigDecimal promotion in the +', *', etc. clojure.core functions?
When I run the following code in the REPL:
(* 2 Double/MAX_VALUE) ;; ##Inf, Doesn't auto-promote as was expected.
(*' 2 Double/MAX_VALUE) ;; ##Inf, Expected that it would auto promote.
Following cases also didn't work:
(*' Double/MAX_VALUE 2) ;; ##Inf, Moving around the arguments.
(*' 2.0 Double/MAX_VALUE) ;; ##Inf, Using a Double literal instead.
(*' Double/MAX_VALUE 2.0) ;; ##Inf
(*' Double/MAX_VALUE 2.0M) ;; ##Inf, Using a BigDecimal literal instead.
(*' 2.0M Double/MAX_VALUE) ;; ##Inf
I decided to check the Clojure compiler source for promotion, and based on my limited understanding of the code I see that DoubleOps is using the implementation of addP of OpsP abstract class (which just calls the normal add function) while there is one present for LongOps which can be found here.
Is this a bug? And if yes, I would like to work on the fix and I'll check the Development page of Clojure to do the needfull.