Timothy Baldridge <tbaldri...@gmail.com> writes: >> 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")"
I thought I could trick the reader by writing :jaja\u0020nee, but it won't work. Thereby, I discovered that clojure diverges quite a bit from java in its unicode escapes handling. Whereas in java, you can replace every character in the source code by its unicode sequence, in clojure you cannot. For example, this is all legal java: "foo\u0022 // => "foo" 1 \u002b 2 // => 3 // class Foo { int x; } \u0063\u006C\u0061\u0073\u0073\u0020\u0046\u006F\u006F\u0020\u007B\u0020\u0069\u006E\u0074\u0020\u0078\u003B\u0020\u007D But the clojure reader doesn't accept "foo\u0022 as a valid string, and neither is (\u002b 1 2) a valid call of clojure.core/+. So basically, in java unicode escapes are replaced before parsing, whereas in clojure any unicode escape evaluates to a character, e.g., (\u002b 1 2) is (\+ 1 2), not (+ 1 2). Well, I think the clojure way is the saner one. And if you really need to instantiate (defrecord इ [x]) as (\u0907. 1), you can add your own `with-replaced-unicode' macro and be done. Bye, Tassilo -- 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