On Feb 28, 10:34 am, joshua-choi <rbysam...@gmail.com> wrote:
> As a small note, according tohttp://clojure.org/reader, Clojure
> keywords and symbols are allowed to contain only alphanumeric
> characters, *, +, !, -, _, and ?. Spaces aren’t allowed, but the
> keyword function allows them anyway because it doesn’t do any checking
> for validity for performance. I’m told that it’s up to the programmer
> to make sure that only valid keywords are created.

Thanks for those details.

> I agree that clojure.contrib.json should default to string keys,
> because keywords are so limited. The thing is, when
> clojure.contrib.json *does* convert JSON keys into Clojure keywords,
> should it check for validity and fail when it cannot create a valid
> keyword?

I personally would really appreciate the check, and fail with a sane
message.

Ultimately, I believe that allowing keywords to be created that
violate the language spec is an error and a meaningful error should be
thrown.
I believe correctness should be more important than speed when core
language functionality is concerned.

The current situation is that I can legally create Clojure structs
that fail to serialize correctly. This is a fundamental component of
the language that simply must work correctly. If not, incidental
complexity is increased.

For an example outside of JSON: recently Compojure changed how it
works so the HTTP request properties are all converted to keywords by
default. I can see the appeal, but now anyone using Compojure has the
increased incidental complexity of possible keyword violations.
Imagine if you were integrating with PayPal or some system that had
HTTP parameters with characters that were not allowed by the Clojure
spec. I really don't want to worry about such things when creating
software with Clojure.

I'm starting to think that perhaps keywords should only be used in
Clojure source code as syntactic sugar to access maps - but the recent
changes to Clojure have made them less useful in this regard because
maps now have to actually contain keywords instead of the keyword name
string.

I think this is something that could be a constant source of
difficulty with Clojure. I'm curious what others think.

Cheers.

-- 
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