This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-11-29
Channels
- # adventofcode (11)
- # aws (2)
- # bangalore-clj (8)
- # beginners (92)
- # boot (2)
- # calva (26)
- # cider (1)
- # clj-kondo (4)
- # cljs-dev (4)
- # clojure (54)
- # clojure-berlin (5)
- # clojure-houston (6)
- # clojure-italy (12)
- # clojure-nl (7)
- # clojure-uk (39)
- # clojurescript (12)
- # clojutre (6)
- # cryogen (1)
- # cursive (15)
- # datomic (11)
- # duct (1)
- # events (5)
- # fulcro (14)
- # jackdaw (1)
- # joker (2)
- # malli (15)
- # mental-health (1)
- # off-topic (35)
- # reagent (2)
- # reitit (24)
- # rewrite-clj (3)
- # shadow-cljs (19)
- # vim (11)
I'm having problems getting this to work in CLJS. It works in CLJ though:
(defprotocol IBox
(setVal [_ _])
(getVal [_]))
(deftype Foo [^:mutable v]
IBox
(setVal [this x]
(set! (.-v this) x))
(getVal [this] v))
(defn test-type []
(let [x (Foo. 10)]
(setVal x 11) ;; No protocol method IBox.setVal defined for type number: 11
(println (getVal x))))
it's because of the underscores?
(defprotocol IBox
(setVal [_this _val])
(getVal [_this]))
does seem to work 😕I am not sure whether ^:mutable
has any effect in ClojureScript, but that probably isn't the root cause of whatever problems you are seeing.
Maybe it gets confused with two args that have the same name, regardless of what that name is?
that seems correct. clj also handles:
(defprotocol IBox
(setVal [x x])
(getVal [_]))
well, I'm surprised 🙂if this is a bug, I'd be happy to post an issue. if it isn't a bug, a compiler warning would be appropriate maybe?