Fork me on GitHub
#clojure-dev
<
2019-12-19
>
p-himik15:12:39

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.

ghadi16:12:10

this is not canonical documentation

sogaiu16:12:57

i know, but it can give an idea of what others have noted and used

Alex Miller (Clojure team)16:12:15

seems very weird to take a keyword as a namespace

Alex Miller (Clojure team)16:12:43

so I'd say that seems weird in cljs. surely clj's docstring could be more specific.

p-himik16:12:04

I use it pretty often. Right now with bidi, for example, as IDs of nested routes.

Alex Miller (Clojure team)16:12:25

well, that's a cljs invention

p-himik16:12:10

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.

Alex Miller (Clojure team)16:12:43

I don't think there is a general answer

Alex Miller (Clojure team)16:12:00

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

Alex Miller (Clojure team)16:12:00

I think the best I can say in this particular case is that this is undefined in Clojure and non-portable across dialects

👍 4