Created
June 14, 2010 21:30
-
-
Save marick/438337 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
(defn world [] | |
(println "executing root binding") | |
"root value") | |
(defn f [ignored-value] | |
(println "within f, world at" world "produces" (world)) | |
(world) | |
) | |
(println "Root world function is at" world) | |
;; Root world function is at #<user$world__1 user$world__1@4b947496> | |
(println "---- given (f 1), the nested binding for world is used") | |
(def simple-f | |
(binding [world (fn [] "bound value")] | |
(f 1))) | |
(println "result of execution was:" simple-f) | |
;; within f, world at #<user$fn__13$fn__15 user$fn__13$fn__15@11e7c5cb> produces bound value | |
;; result of execution was: bound value | |
(println) | |
(println "---- given (map f [1]), get wrong (world) AND println values") | |
(def map-f | |
(binding [world (fn [] "bound value")] | |
(map f [1]))) | |
(println "result of execution was:" map-f) | |
;; result of execution was: (executing root binding | |
;; within f, world at #<user$world__1 user$world__1@4b947496> produces root value | |
;; executing root binding | |
;; root value) | |
;; result of execution was: bound value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment