<< Back to previous view

[CLJ-463] Strip leading colons when creating keywords from single strings Created: 20/Oct/10  Updated: 19/Nov/10  Resolved: 19/Nov/10

Status: Closed
Project: Clojure
Component/s: None
Affects Version/s: None
Fix Version/s: Backlog

Type: Enhancement
Reporter: Anonymous Assignee: Chas Emerick
Resolution: Declined Votes: 0
Labels: None


This seems unfortunate:

=> (-> :foo str keyword)

Symbols are far saner in this regard:

=> (-> 'foo str symbol)

Simply stripping leading colons from strings prior to turning them into keywords should suffice. The 2-arity Keyword.intern method and clojure.core/keyword fn should be left intact, so as to provide an escape hatch for those that really do need colon-prefixed keywords.

Comment by Assembla Importer [ 20/Oct/10 4:44 AM ]

Converted from http://www.assembla.com/spaces/clojure/tickets/463
463-strip-keyword-colons.diff - https://www.assembla.com/spaces/clojure/documents/bKmJCu2_Wr36meeJe5cbLA/download/bKmJCu2_Wr36meeJe5cbLA

Comment by Assembla Importer [ 20/Oct/10 4:44 AM ]

cemerick said: [file:bKmJCu2_Wr36meeJe5cbLA]

Comment by Stuart Halloway [ 29/Oct/10 10:00 AM ]

I am uncomfortable with this. If I say (keyword "::foo"), what am I asking for? I almost wonder if this should throw an exception.

Comment by Rich Hickey [ 29/Oct/10 10:07 AM ]

I think (keyword "::foo") (and any more leading colons) should fail, and this patch should only strip one colon.

Comment by Chas Emerick [ 29/Oct/10 11:11 AM ]

Updated patch forthcoming.

Comment by Chas Emerick [ 19/Nov/10 10:07 AM ]

After thinking about this for a while, I've now reversed my position, and am in favor or retaining the current functionality. Thanks for the pushback.

As for throwing exceptions on colon-prefixed, un-namespaced keywords, I'm not certain that that's a good idea. People use keywords to hold all sorts of data, use them as map keys and lookup fns, etc.

Generated at Thu Jan 18 20:17:54 CST 2018 using JIRA 4.4#649-r158309.