rcf icon indicating copy to clipboard operation
rcf copied to clipboard

Sequential rewriting broken in cljs

Open ggeoffrey opened this issue 2 years ago • 1 comments

Cljs macroexpansion needs to sequence test steps using a continuation passing style (we cannot block on a js runtime) Current rewriting does not sequence steps correctly, the problem is exhibited by rcf/with.

ggeoffrey avatar Jul 22 '22 11:07 ggeoffrey

Workaround:

(defmacro with
  "Resource cleanup helper, based on missionary's dependency-free Task protocol, see https://github.com/leonoel/task"
  [dispose-fn & body]
  `(let [dispose# ~dispose-fn
         #_#_res# (do ~@body)]    ; busted, introduces second rewrite pass - see https://github.com/hyperfiddle/rcf/issues/56
     ~@body
     (dispose#) ; workaround - due to async dependency on body, must be in same RCF rewrite pass
     #_res#))

dustingetz avatar Jul 22 '22 15:07 dustingetz