Hello,

I'm trying to create a small wrapper for the java money api. The api uses 
method overloading. 


For example: 
https://github.com/JavaMoney/jsr354-api/blob/master/src/main/java/javax/money/MonetaryAmount.java

has methods

* multiply(long x)
* multiply(double x)
* multiply(Number x)

In clojure i want to do something like

(defn multiply[^MonetaryAmount amount multiplicant]
  (.multiply amount multiplicant))

Ofcourse i get reflection warnings. I can add typehints to the multiplicant 
to 1 of the 3 versions above, but obviously that doesnt allow me to expose 
the other versions.

What would be the most idiomatic choice to handle this?

Things i considered myself are:

* multimethods: they can only work on the boxed versions of long/double
* have different function names like multiplyLong multiplyDouble.... but 
that doesnt sound right either. 

Kr,

Jo

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to