Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@pthatcher
Created February 24, 2010 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pthatcher/312898 to your computer and use it in GitHub Desktop.
Save pthatcher/312898 to your computer and use it in GitHub Desktop.
;; 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