Those are convincing arguments/examples that spaces should be allowed in 
keywords.

Your solution to enhance "pr":

(pr-str k) ; as in your example
"(keyword "jaja nee")"

should work.

Btw., symbols seem to have the exact same issue:

user=> (def s (symbol "with space"))
#'user/s
user=> s
with space
user=> (pr-str s)
"with space"
user=> (read-string (pr-str s))
with
user=> 

Is this a bug?

-FrankS.


On Mar 6, 2012, at 11:56 AM, Timothy Baldridge wrote:

>> I don't think you're supposed to use spaces in keywords.
> 
> 
> Using spaces in keywords is completely valid, as is using spaces in
> symbols. You just have to be aware that there may be times when you
> can't represent them in a literal form. pr-str could be extended to do
> this though:
> 
> (pr-str :foo)
> ":foo"
> 
> (pr-str k) ; as in your example
> "(keyword "jaja nee")"
> 
> There are many times when you may actually want to have spaces as
> keywords. Consider the following json:
> 
> {"first name" : "John"
> "last name" : "Doe"
> "age" : 42}
> 
> If we convert this json to clojure, it would be nice to be able to do:
> 
> user=> (:age data)
> 42
> 
> And we can still do this:
> 
> user=> ((keyword "first name") data)
> "John"
> 
> Why restrict the user needlessly?
> 
> 
> Timothy
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "Clojure" group.
> To post to this group, send email to clojure@googlegroups.com
> Note that posts from new members are moderated - please be patient with your 
> first post.
> To unsubscribe from this group, send email to
> clojure+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/clojure?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to