your extension point on Number is never fired because 10 is a Long.
Generally speaking extending protocols to interfaces is not
suggested...I've been bitten a couple of times in particular whenever
I'm extending to 2 different interfaces that *are* related...You can
certainly do it but you have to have sure that your top interface comes
first than the others.
Your example is actually fine...try "(hello (int 10))" - you should see
"hello"
Jim
On 02/08/13 11:44, Phillip Lord wrote:
I want to use extend-type to support a protocol both on a class and it's
subclasses. But I don't know how to do a superclass call. So for
instance, with this code....
(defprotocol PThree
(hello [this]))
(extend-type
Number PThree
(hello [this]
(if (= 10 this)
"hello")))
(extend-type
Long PThree
(hello [this]
(if (= 5 this)
"goodbye")))
;; this return "goodbye"
(hello 5)
;; this returns nil
(hello 10)
I really want (hello 10) to return "hello". But the extend-type of Long
takes precedence. How can I call the implementation on the superclass
instead?
Phil
--
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.