[CLJ-891] make (symbol foo "bar") work with foo being a namespace Created: 05/Dec/11 Updated: 02/Mar/12
|Fix Version/s:||Reviewed Backlog|
I've run across the need to do (symbol ns "bar") a few times, and the existing approach (symbol (name (ns-name ns)) "bar") just doesn't seem like it ought to be the only way to do the job. Includes a patch to make this work, by adding a new arity to Symbol.intern().
Some discussion on this idea, here: https://groups.google.com/forum/#!topic/clojure/n25aZ5HA7hc/discussion
|Comment by Stuart Halloway [ 09/Dec/11 9:39 AM ]|
I am not sure I like this, but I would like a rethink of names and namespaces. Doing a lot of cross language work, it would be great to have protocols for "I have a name" and for "I have a namespace".
With such protocols in place, it would also be possible to separately consider implementing symbol et al in terms of them.
|Comment by Kevin Downey [ 09/Dec/11 12:24 PM ]|
Named being a protocol or an interface seems orthogonal to being able to create a symbol qualified with a namespace when you have a namespace in hand.
I don't think the patch goes far enough, not only should (symbol ns "foo") be supported, but also (symbol ns 'foo), given that (symbol 'foo) works and (symbol "foo") works, (symbol 'bar 'foo) should also work, but doesn't.
if Named is a protocol, and if you extend it to String, and if you make the symbol function create symbols from one or two Named things you still end up having to do (symbol (ns-name ns) 'foo) or (symbol (ns-name ns) "foo")
|Comment by Joe Gallo [ 16/Dec/11 4:18 PM ]|
Stuart, I'm not opposed to the idea of separate protocols for Named and Namespaced. Where should I go about creating a proposal to create those protocols and get them into clojure? I'm interested in doing the leg-work, or being a part of it. But as an outsider, I don't know what to do next – creating a ticket in Jira exhausted my knowledge of the process.
|Comment by Frank Siebenlist [ 02/Mar/12 4:53 PM ]|
The same enhancement that joe suggests for symbol, would also apply to keyword.
Probably same/similar solution applies to both issues.