Re: java method overloading and clojure interop

2015-07-09 Thread Jo Geraerts
Op woensdag 8 juli 2015 05:20:51 UTC+2 schreef Herwig Hochleitner: The way I would do it: Define multiply as a function calling (.multiply amount ^Number x), for higher order usage, and then add an :inline function to its metadata, which returns `(.multiply ~amount ~x). That acts as a

Re: java method overloading and clojure interop

2015-07-09 Thread Herwig Hochleitner
:inline-arities tells the compiler, which arities (i.e. parameter counts) should be inlined: https://github.com/clojure/clojure/blob/9d70bc1051ec8117df6436e07474c586ea9e85b0/src/jvm/clojure/lang/Compiler.java#L6596 2015-07-09 9:49 GMT+02:00 Jo Geraerts j...@umask.net: Op woensdag 8 juli 2015

Re: java method overloading and clojure interop

2015-07-08 Thread Mike Rodriguez
Good call on the auto-boxing. I wasn't considering that before, but obviously it is important. Nice insight into :inline. I never really did understand the usefulness of it before. On Tuesday, July 7, 2015 at 10:20:51 PM UTC-5, Herwig Hochleitner wrote: 2015-07-07 15:04 GMT+02:00 Jo

Re: java method overloading and clojure interop

2015-07-08 Thread Jo Geraerts
Herwig Hochleitner schreef op 2015-07-08 05:20: 2015-07-07 15:04 GMT+02:00 Jo Geraerts j...@umask.net [1]: * multiply(long x) * multiply(double x) * multiply(Number x) In clojure i want to do something like (defn multiply[^MonetaryAmount amount multiplicant]   (.multiply amount

java method overloading and clojure interop

2015-07-07 Thread Mike Rodriguez
consional = conditional Typo sorry. -- 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

Re: java method overloading and clojure interop

2015-07-07 Thread Herwig Hochleitner
2015-07-07 15:04 GMT+02:00 Jo Geraerts j...@umask.net: * 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)) Function parameters in Clojure, are generally

java method overloading and clojure interop

2015-07-07 Thread Mike Rodriguez
You can do some consional instance? checks at runtime and type hint each method call appropriately. Java would determine the correct method based on the type information known to the compiler at compile time. You don't have that given in Clojure so you have to runtime check the type and

java method overloading and clojure interop

2015-07-07 Thread Jo Geraerts
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