Hi,
I'm writing my first ClojureScript program. I defined a protocol for a
query language which I wanted to extend to various data types, including
keywords.
However keywords are strings when it comes to dispatch. Is this a bug, or
by design?
ClojureScript:cljs.user> (defprotocol Foo (-a [x] "sample"))
nil
ClojureScript:cljs.user> (extend-protocol Foo
Keyword
(-a [x] (print "keyword")))
#<
function (x) {
return cljs.core.print.call(null, "keyword");
}
>
ClojureScript:cljs.user> (-a :foo)
"Error evaluating:" (-a :foo) :as
"cljs.user._a.call(null,\"\\uFDD0'foo\");\n"
org.mozilla.javascript.JavaScriptException: Error: No protocol method
Foo.-a defined for type string: ?'foo (<cljs repl>#22)
at <cljs repl>:22 (anonymous)
at <cljs repl>:14 (_a)
at <cljs repl>:7 (anonymous)
at <cljs repl>:7
If I extend to js/String it works.
--
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