Skip to content

Instantly share code, notes, and snippets.

@fasterthanlime
Last active August 29, 2015 14:10
Show Gist options
  • Save fasterthanlime/1124beddcc3ec205b897 to your computer and use it in GitHub Desktop.
Save fasterthanlime/1124beddcc3ec205b897 to your computer and use it in GitHub Desktop.
; `binding` definition from Clojuredocs.org:
; (binding bindings & body)
;
; binding => var-symbol init-expr
;
; Creates new bindings for the (already-existing) vars, with the
; supplied initial values, executes the exprs in an implicit do, then
; re-establishes the bindings that existed before. The new bindings
; are made in parallel (unlike let); all init-exprs are evaluated
; before the vars are bound to their new values.
(def ^:dynamic foo "")
(def ^:dynamic bar "")
(defn something []
(binding [foo "non"
bar (str foo "conformant")]
(prn bar)))
; Since the bindings are made in parallel, this should print
; "conformant", right?
; It does on Clojure 1.6.0, but doesn't on ClojureScript 0.0-2156
; see generated code below
// Compiled by ClojureScript 0.0-2156
goog.provide('wtf_require.client');
goog.require('cljs.core');
wtf_require.client.foo = "";
wtf_require.client.bar = "";
wtf_require.client.something = (function something() {
var foo4767 = wtf_require.client.foo;
var bar4768 = wtf_require.client.bar;
try {
wtf_require.client.foo = "non";
wtf_require.client.bar = [cljs.core.str(wtf_require.client.foo), cljs.core.str("conformant")].join('');
return cljs.core.prn.call(null, wtf_require.client.foo, wtf_require.client.bar);
} finally {
wtf_require.client.bar = bar4768;
wtf_require.client.foo = foo4767;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment