Axiom, a computer algebra system I maintain,
can dispatch on return type. I am looking at
the things Clojure can do that might support
the Spad language (the mathematical language
in Axiom). I could not find a way to adjust
the multimethod to dispatch on return type.
On 12/18/2010 6:41 PM, Meikel Brandmeyer wrote:
Hi,
Am 19.12.2010 um 00:07 schrieb Tim Daly:
Is it possible to dispatch based on the return type/value?
That is, can I write a multimethods dispatch to distinguish
+(float,float) -> float
+(float,float) -> int
(defmulti + (fn [x y ret] (vector (type x) (type y) ret))
(defmethod + [Float Float Float]
...)
(defmethod + [Float Float Integer]
...)
(+ 1.0 2.0 Integer)
(+ 1.0 2.0 Float)
This poses the question: Why do you need that? And: Is Clojure is the right
tool for this job? This sounds more like Haskell.
Sincerely
Meikel
--
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