It's probably worth distinguishing between the "spec" as documented on
clojure.org (or https://github.com/edn-format/edn if you prefer) and what
the reader permits. Symbols are documented to begin with a non-numeric
character (with a special note in the EDN spec about the names of
namespaced symbols following the same first-character rule. Keywords are in
both documents described as following the rules of symbols.

The first char restriction for symbols makes sense, since they're Clojure's
identifier type, and the reader needs to be able to distinguish between a
number like `2M` and a symbol. I haven't thought of a reason it's important
to have the same restriction on keywords, but there may well be one.

Switching gears, you can do this (at least in Clojure 1.5.1):

    (keyword "foo" "1")
    (symbol "foo" "1")

but since the docs say these are invalid, I wouldn't recommend using it in
non-throw-away code.



On Wed, Jul 31, 2013 at 2:59 PM, Brent Millare <brent.mill...@gmail.com>wrote:

> I've been discovering in my code that namespaced identifiers are a
> wonderful thing. In particular, I am found of namespaced integers as an id.
>
> Keywords usually serve the role as identifiers, but currently, the spec
> does not allow namespaced integers, which is odd since integers are valid
> as keywords and you can namespace words.
>
> Again in table form:
>
> Keyword...
> name-starts-with | has-namespace | is-valid?
> letter, no, yes
> letter, yes, yes
> number, no, yes
> number, yes, no <-- This is odd
>
> Can we change this so we don't get stack traces like so?
>
> clojure.lang.LispReader$ReaderException: java.lang.RuntimeException:
> Invalid token: :asdf/3a
>                                LispReader.java:220
> clojure.lang.LispReader.read
>                                      core.clj:3407 clojure.core/read
>                                      core.clj:3405 clojure.core/read
>                          interruptible_eval.clj:52
> clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
>                                       main.clj:257 clojure.main/repl[fn]
>                                       main.clj:257 clojure.main/repl[fn]
>                                       main.clj:277 clojure.main/repl[fn]
>                                       main.clj:277 clojure.main/repl
>                                   RestFn.java:1096
> clojure.lang.RestFn.invoke
>                          interruptible_eval.clj:56
> clojure.tools.nrepl.middleware.interruptible-eval/evaluate[fn]
>                                       AFn.java:159
> clojure.lang.AFn.applyToHelper
>                                       AFn.java:151 clojure.lang.AFn.applyTo
>                                       core.clj:617 clojure.core/apply
>                                      core.clj:1788
> clojure.core/with-bindings*
>                                    RestFn.java:425
> clojure.lang.RestFn.invoke
>                          interruptible_eval.clj:41
> clojure.tools.nrepl.middleware.interruptible-eval/evaluate
>                         interruptible_eval.clj:171
> clojure.tools.nrepl.middleware.interruptible-eval/interruptible-eval[fn]
>                                      core.clj:2330 clojure.core/comp[fn]
>                         interruptible_eval.clj:138
> clojure.tools.nrepl.middleware.interruptible-eval/run-next[fn]
>                                        AFn.java:24 clojure.lang.AFn.run
>                       ThreadPoolExecutor.java:1145
> java.util.concurrent.ThreadPoolExecutor.runWorker
>                        ThreadPoolExecutor.java:615
> java.util.concurrent.ThreadPoolExecutor$Worker.run
>                                    Thread.java:724 java.lang.Thread.run
> Caused by: java.lang.RuntimeException: Invalid token: :asdf/3a
>                                      Util.java:219
> clojure.lang.Util.runtimeException
>                                LispReader.java:326
> clojure.lang.LispReader.interpretToken
>                                LispReader.java:211
> clojure.lang.LispReader.read
>
> --
> --
> 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 unsubscribe from this group and stop receiving emails from it, send an
> email to clojure+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
http://elhumidor.blogspot.com/

-- 
-- 
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 unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to