hoplon / javelin

Spreadsheet-like dataflow programming in ClojureScript.
803 stars 44 forks source link

set! in cell body has no effect #4

Closed cemerick closed 11 years ago

cemerick commented 11 years ago

I would expect this interaction to show obj.foo being updated:

(def obj (js-obj))
; #<[object Object]>
;= nil
(def a (cell 0))
; #<[object Object]>
;= nil
(def b (cell (do (println a)
                 (set! (.-foo obj) a))))
; 0
; #<[object Object]>
;= nil
(js->clj obj)
;= {}
(reset! a 12)
; 12
;= 12
(js->clj obj)
;= {}

If I get the set! out of the body of cell, then it works as expected:

(def obj (js-obj))
; #<[object Object]>
;= nil
(def a (cell 0))
; #<[object Object]>
;= nil
(def b (let [set-foo #(set! (.-foo obj) %)]
         (cell (do (println a)
                   (set-foo a)))))
; 0
; #<[object Object]>
;= nil
(js->clj obj)
;= {"foo" 0}
(reset! a 12)
; 12
;= 12
(js->clj obj)
;= {"foo" 12}
alandipert commented 11 years ago

set! support is in: 893203bf718c083f4538845dbb82dd8e47b029c7. The target argument cannot be a Cell. If you need a formula for a place, use aset with possibly Cell arguments.

For the remaining unsupported macros and specials, see https://github.com/tailrecursion/javelin/blob/master/src/cljs/tailrecursion/javelin/specials.cljs

cemerick commented 11 years ago

Confirmed fixed, thanks! :-)