Fork me on GitHub

On the subject of namespaced keywords, how "legal" / "defined" is it to do (keyword "foo/bar") as opposed to (keyword "foo" "bar") (since they both produce the same value — according to identical?).


(the context for me here is the :identifiers function passed into various java.jdbc functions, that is used as (keyword (identifiers col-name)) so you could pass in (partial str table-name "/") and get namespaced keywords out… which is useful but seems sketchy)

Alex Miller (Clojure team)04:04:06

either is fine, not sure what the question is


The question is: can the argument to keyword legally contain / and is that guaranteed to be well-defined behavior?


In other words, could I rely on that not breaking in a future release of Clojure?


IIRC it's Keyword.intern(String nsname), Keyword.intern(String ns, String name)


There have been discussions in the past about what is really legal for the argument to keyword — things like (keyword "I have spaces") and so on… which all "work" but violate some of the documented rules about legal keywords etc.


which does split on the first / to get namespace and name


So I guess (keyword "foo/bar") is as legal as (symbol "foo/bar") then...


I make no claim of legality, but it will work.


Yeah, I’m mostly concerned with legality and intent here. I don’t really want to rely on something that "just happens to work" but isn’t something that Clojure/core think should be legal simple_smile

Alex Miller (Clojure team)12:04:41

And programmatic creation of keywords that are not readable by the reader is both fine and useful


@alexmiller: if you get a chance to contact Tom Faulhaber can you let him know that the autodoc for tools.analyzer appears to be broken? those types shouldn't exist anymore

Alex Miller (Clojure team)15:04:39

How long has it been? I think that stuff regenerates in a nightly batch.


those types have been deleted months ago


I might have force-pushed in between, that's possibly confused autodoc