This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-02-21
Channels
- # architecture (9)
- # beginners (192)
- # boot (1)
- # bristol-clojurians (2)
- # cider (213)
- # cljs-dev (10)
- # clojure (195)
- # clojure-art (2)
- # clojure-austin (3)
- # clojure-belgium (4)
- # clojure-dev (4)
- # clojure-dusseldorf (1)
- # clojure-gamedev (9)
- # clojure-greece (21)
- # clojure-italy (27)
- # clojure-losangeles (2)
- # clojure-russia (1)
- # clojure-seattle-old (2)
- # clojure-serbia (1)
- # clojure-spec (114)
- # clojure-uk (136)
- # clojured (2)
- # clojurescript (100)
- # community-development (19)
- # core-async (12)
- # cursive (7)
- # duct (1)
- # figwheel (7)
- # fulcro (96)
- # hoplon (4)
- # jobs (2)
- # lein-figwheel (28)
- # leiningen (2)
- # luminus (14)
- # lumo (3)
- # off-topic (11)
- # om-next (2)
- # pedestal (10)
- # planck (11)
- # portkey (2)
- # proton (1)
- # protorepl (19)
- # re-frame (27)
- # reagent (12)
- # shadow-cljs (82)
- # spacemacs (42)
- # specter (15)
- # sql (3)
ClojureScript appears to not do bindings in parallel (as indicated in the docstring for binding
). True? Is the fact that the last form evaluates to 3
instead of 2
a bug?
cljs.user=> (def ^:dynamic *a* 1)
#'cljs.user/*a*
cljs.user=> (def ^:dynamic *b* nil)
#'cljs.user/*b*
cljs.user=> (binding [*a* 2 *b* (inc *a*)] *b*)
3
In Clojure (binding [*a* 2 *b* (inc *a*)] *b*)
evaluates to 2
. This follows the docstring portion indicating "all init-exprs are evaluated before the vars are bound to their new values" (my emphasis added)
Interestingly, if you check out https://dev.clojure.org/jira/browse/CLJ-152 and the mailing list link posted, you unfortunately don't get an answer as to why bindings are done in parallel. Perhaps it makes it easier to atomically unwind all bindings if done this way? Anyway, the rationale is no longer important; I guess we just have to accept that parallel binding is the Clojure behavior.