Oddity with set! and ..

101 views
Skip to first unread message

Paul Butcher

unread,
Jan 12, 2014, 5:25:26 AM1/12/14
to clojur...@googlegroups.com
I'm still finding my feet with ClojureScript, so please forgive any stupid mistakes. I've just hit an oddity when using set! with ..

I have a page with a very simple SVG on it:

<svg width="500" height="100">
  <circle id="circle" cx="20" cy="20" r="10" style="stroke: none; fill: #ff0000;"/>
</svg>

And a very simple little piece of ClojureScript that animates it:

(let [circle (dom/getElement "circle")]
  (go-loop [x 20]
    (<! (timeout 10))
    (set! (.-value (.-baseVal (.-cx circle))) x)
    (recur (inc x))))

This all works fine. If, however, I change the set! to:

(set! (.. circle -cx -baseVal -value) x)

I get the error:

Wrong number of args (3) passed to: core$-DOT

But the same structure works fine outside of the go-loop. So this, for example, compiles and runs exactly as I'd expect:

(set! (.. (dom/getElement "circle") -cx -baseVal -value) 200)

I'd be very grateful for any pointers as to what's up.

Thanks,

--
paul.butcher->msgCount++

Silverstone, Brands Hatch, Donington Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
Skype: paulrabutcher




Paul Butcher

unread,
Jan 12, 2014, 6:10:23 AM1/12/14
to clojur...@googlegroups.com
Update: this definitely seems to be something to do with being within the go-loop. Hoisting it out into a separate function also fixes the problem:

(defn setx [elem x]
  (set! (.. elem -cx -baseVal -value) x))

(let [circle (dom/getElement "circle")]
  (go-loop [x 20]
    (<! (timeout 10))
    (setx circle x)
    (recur (inc x))))

--
paul.butcher->msgCount++

Silverstone, Brands Hatch, Donington Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
Skype: paulrabutcher




David Nolen

unread,
Jan 12, 2014, 1:52:31 PM1/12/14
to clojur...@googlegroups.com
core.async has (and had) some bugs around dot forms. File an issue with core.async.

David


--
Note that posts from new members are moderated - please be patient with your first post.
---
You received this message because you are subscribed to the Google Groups "ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojurescrip...@googlegroups.com.
To post to this group, send email to clojur...@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Paul Butcher

unread,
Jan 12, 2014, 4:40:15 PM1/12/14
to clojur...@googlegroups.com
On 12 Jan 2014, at 18:52, David Nolen <dnolen...@gmail.com> wrote:

core.async has (and had) some bugs around dot forms. File an issue with core.async.

Thanks for the response, David - will do.

Cheers,

Paul Butcher

unread,
Jan 12, 2014, 6:28:10 PM1/12/14
to clojur...@googlegroups.com
On 12 Jan 2014, at 21:40, Paul Butcher <pa...@paulbutcher.com> wrote:

On 12 Jan 2014, at 18:52, David Nolen <dnolen...@gmail.com> wrote:

core.async has (and had) some bugs around dot forms. File an issue with core.async.

Thanks for the response, David - will do.

Reply all
Reply to author
Forward
0 new messages