Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (defprotocol BlaBla
- (bla [this]))
- ;; This extend form does not compile
- (extend-protocol BlaBla
- (class 17) (bla [this] (inc this))
- (class "s") (bla [this] (reverse this))
- (class \s) (bla [this] "foo"))
- ;; This is the exception:
- nth not supported on this type: Character
- [Thrown class java.lang.UnsupportedOperationException]
- Backtrace:
- 0: clojure.lang.RT.nthFrom(RT.java:835)
- 1: clojure.lang.RT.nth(RT.java:785)
- 2: clojure.core$emit_hinted_impl$hint__5517$fn__5519.invoke(core_deftype.clj:710)
- 3: clojure.core$map$fn__3811.invoke(core.clj:2432)
- 4: clojure.lang.LazySeq.sval(LazySeq.java:42)
- 5: clojure.lang.LazySeq.seq(LazySeq.java:60)
- 6: clojure.lang.RT.seq(RT.java:466)
- 7: clojure.lang.RT.countFrom(RT.java:519)
- 8: clojure.lang.RT.count(RT.java:512)
- 9: clojure.lang.Cons.count(Cons.java:49)
- 10: clojure.lang.Compiler.analyze(Compiler.java:6207)
- ;; After commenting the two last 2 method defs and reevaling...
- (extend-protocol BlaBla
- (class 17) (bla [this] (inc this))
- ;;(class "s") (bla [this] (reverse this))
- ;;(class \s) (bla [this] "foo")
- )
- ;; ... I can now do:
- => (bla 17)
- 18
- ;; So it seems to work fine if there's only one class-exp/method-def
- ;; pair... Why?
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement