There's a discrepancy in keyword
behavior between Clojure and ClojureScript:
cljs.user=> (keyword :a :b)
:a/b
clj.user=> (keyword :a :b)
Execution error (ClassCastException) at dev/eval103787 (form-init191682565753033842.clj:1).
class clojure.lang.Keyword cannot be cast to class java.lang.String (clojure.lang.Keyword is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
Given that providing keywords for both ns
and name
arguments is explicitly handled in ClojureScript, I assume that it's an issue on Clojure's side. Especially since the docstrings don't say anything about argument types.https://clojuredocs.org/clojure.core/keyword has what looks like relevant info
seems very weird to take a keyword as a namespace
so I'd say that seems weird in cljs. surely clj's docstring could be more specific.
I use it pretty often. Right now with bidi
, for example, as IDs of nested routes.
well, that's a cljs invention
How are such things handled in general? Are they just left to be? Since changing the behavior of CLJS in this case would be backward incompatible.
I don't think there is a general answer
offhand, I can think of cases where clj does things cljs doesn't, the opposite of that, and even cases where they are incompatible in some ways
I think the best I can say in this particular case is that this is undefined in Clojure and non-portable across dialects
i know, but it can give an idea of what others have noted and used