Fork me on GitHub
#cljs-dev
<
2022-07-22
>
p-himik05:07:43

A bug in (defmethod parse 'set! ...) prevents (set! x -y false) from working - it treats false in there as a flag saying that there are just 2 arguments instead of 3. Given that false could also be nil, perhaps the (if alt ...) check should be replaced with an explicit check for the amount of arguments to set!. https://clojurians.slack.com/archives/C03S1L9DN/p1658434779619089

john06:07:33

Looks like set! has always expected the target to be a paren-wrapped thing https://clojure.org/reference/java_interop#set

john06:07:38

I agree though, that other syntax would be convenient

p-himik06:07:56

That other syntax has been there for a long time, it's just not as well documented.

p-himik06:07:21

(defmethod parse 'set!
  [_ env [_ target val alt :as form] _ _]
  (let [[target val] (if alt
                       ;; (set! o -prop val)
                       [`(. ~target ~val) alt]
                       [target val])]
    ...))

john06:07:08

I feel cheated! All these years, all those parens

😄 1
p-himik06:07:14

Note that it only works in CLJS, not in CLJ.

john06:07:08

Right. So prolly not a likely change

john06:07:14

I've always wanted the other syntax though... maybe because I've seen it and so just intuitively thought it should be possible

borkdude07:07:47

Set! With symbol Also works in deftype with mutable fields. Sorry for capitals, from iPhone

👍 1
thheller07:07:46

probably should take it to http://ask.clojure.org. IMHO (set! ctx -imageSmoothingEnabled false) should work and is just confusing if false-ish values don't work. no brainer change if you ask me