(ns foo.bar)
(def ^:const n 3)
(def ^:const m 4)
(let [x 4]
(case x
n 1
m 2
7 3
"hi" 4
:no-match))
... that seems wrong.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
clojure+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I'll leave the choice of what to do in ClojureScript up to David.
Btw, I believe there actually is a case* in Clojure already which is part of the implementation details.
At any rate, I would like to put in either a documentation issue (if it's a feature that ClojureScript's "case" does not work like Clojure's) or else a defect issue (if it's a bug).
And resulting enhancement requests Alex asked for:
https://dev.clojure.org/jira/browse/CLJ-1367
https://dev.clojure.org/jira/browse/CLJ-1368
For what it's worth (though I realise we don't want to break back compatibility), I find the clojure behavior v surprising given that the parallel switch/case in Java is so frequently used for exactly this sort of const jump table. Intuitively it makes no sense for me that in this one statement you would compare the symbol and not the const value. It actively discourages naming magic constants if you don't want to fall back to slower condp or a map lookup.
Adam
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clo...@googlegroups.com
Note that posts from new members are moderated - please be patient with your first post.
To unsubscribe from this group, send email to
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups "Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.