Created
April 7, 2017 21:49
-
-
Save xiongtx/8095beb4fe80c1af3722dd97ad1d93a0 to your computer and use it in GitHub Desktop.
`with-redefs` problems with laziness
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 two-deep [_] | |
"two-deep") | |
(defn other-two-deep [_] | |
"other-two-deep") | |
(defn one-deep [& args] | |
(map two-deep args)) | |
(defn foo [] | |
(map one-deep (range 0 3))) | |
(with-redefs [two-deep other-two-deep] | |
(foo)) | |
;; => (("two-deep") ("two-deep") ("two-deep")) | |
(with-redefs [two-deep other-two-deep] | |
(doall (foo))) | |
;; => (("other-two-deep") ("other-two-deep") ("other-two-deep")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment