Hi Alan

Excuse me if I didn't understand your question, but I think a type hint
would solve. Maybe you could abstract this for the final user in Clojure.

(.add (Complex. 1.0 2.0) ^double 2)

On Sat, May 2, 2015 at 8:53 AM, Alan Forrester <
alanmichaelforres...@googlemail.com> wrote:

> Hello
>
> I'm currently trying to wrap org.apache.commons.math3.complex
>
>
> http://commons.apache.org/proper/commons-math/apidocs/org/apache/commons/math3/complex/Complex.html
>
> to make a complex number library and I have a problem. Many of the
> methods won't work with all Clojure number types. For example,
>
> (.add (Complex. 1.0 2.0) 2)
>
> produces an IllegalArgumentException. The method only works if at
> least one of the arguments is a complex number although the other can
> be a double.
>
> What would be the best way of handling this? Should I just wrap add
> the way it is and explain what types are expected in the
> documentation, or is there a better way of dealing with this issue
> that would allow Clojure number types to be used seamlessly?
>
> Alan
>
> --
> 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.
>

-- 
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