-
-
Save ceterumnet/7b6bfc55874a26160941 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def ^{:dynamic true} a-binding 1) | |
(defn methods [] [(partial map #(% a-binding))]) | |
(defn run-methods [] | |
(let [post-fn (apply comp (methods))] | |
(println "run-posts: " a-binding) | |
(do (post-fn [#(println a-binding %)])))) | |
(with-bindings {#'a-binding 2} (run-methods)) | |
;; this is what happens on this one: | |
iscan-services.db.db> (with-bindings {#'a-binding 2} (run-methods)) | |
run-posts: 2 | |
(1 1 | |
nil) | |
(defn methods2 [] [(partial map (fn [x] (x a-binding)))]) | |
(defn run-methods2 [] | |
(let [post-fn (apply comp (methods2))] | |
(println "run-posts: " a-binding) | |
(do (post-fn [#(println "some data: " a-binding %)])))) | |
(with-bindings {#'a-binding 2} (run-methods2)) | |
;; this is what happens: | |
iscan-services.db.db> (with-bindings {#'a-binding 2} (run-methods2)) | |
run-posts: 2 | |
(some data: 1 1 | |
nil) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment