Fork me on GitHub
#clojure-dev
<
2016-04-09
>
seancorfield02:04:46

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?).

seancorfield02:04:43

(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

seancorfield06:04:30

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

seancorfield06:04:03

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

arrdem06:04:16

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

seancorfield06:04:54

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.

arrdem06:04:11

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

seancorfield06:04:39

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

arrdem07:04:08

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

seancorfield07:04:32

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

bronsa14:04:49

@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? http://clojure.github.io/tools.analyzer/#type-section 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.

bronsa15:04:26

those types have been deleted months ago

bronsa15:04:03

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