Created
February 24, 2010 00:20
-
-
Save pthatcher/312898 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
;; There appears to be a bug in Clojure 1.2's "case" macro. It doesn't work with *global* strings. I'll show some examples and a temporary work around. | |
(def *a* "a") | |
;true | |
(case "a" | |
"a" true | |
false) ;true | |
;true | |
(case *a* | |
"a" true | |
false) | |
;false! | |
(case "a" | |
*a* true | |
false) | |
;false!! | |
(case *a* | |
*a* true | |
false) | |
;still false! | |
(let [a *a*] | |
(case "a" | |
a true | |
false)) | |
;true | |
(condp = *a* | |
*a* true | |
false) | |
;this can be used as a temporary fix | |
(defmacro case-slow [e & clauses] | |
`(condp = ~e ~@clauses)) | |
;true | |
(case-safe *a* | |
*a* true | |
false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment