@borkdude, I am playing in the Clojure REPL trying to understand how namespaced maps apply to symbols. The well understood keyword behaves as expected:
user=> #:foo {:x 1 :bar/y 2}
{:foo/x 1, :bar/y 2}
For less understood symbol, if I follow CLJ-1910 examples, it works:
user=> '#:foo {x 1 :bar/y 2}
{foo/x 1, :bar/y 2}
In my naiveté, I was expecting x to be namespaced here too:
user=> #:foo {'x 1 :bar/y 2}
{x 1, :bar/y 2}
they behave as expected when parsing and sexpr-ing with rewrite-cljc?
round-trip
was just confused about REPL behaviour in my last example.
you should just read this as EDN
'x is really (quote x)
I see how a Clojure program can contain a namespaced map that affects a keyword key, but I don’t yet see how a Clojure program would contain a namespaced map that affects a symbol key.
I guess it is important to remember we are just reading and not running. But I’m still currently a little confused by the namespaced symbol.
You don't understand this one?
user=> '#:foo {x 1 :bar/y 2}
{foo/x 1, :bar/y 2}
so for a namespaced map, unqualified keywords and symbols are auto-namespaced
(apparently)
I had a brain sprain, I think I am ok now.
A Clojure program would just have to use the quote as CLJ-1910 illustrated. So it would just:
(def my-map '#:foo {x 1 :bar/y 2})
(keys my-map)
;; => (foo/x :bar/y)
yes
but this is irrelevant for rewrite-clj since it doesn't do evaluation
yeah, but my brain needed to see an example that would work.
just to understand the concept.
user=> #:clojure.core {x 1 :bar/y 2})
Syntax error compiling at (REPL:0:0).
No such var: clojure.core/x
So it reads as {clojure.core/x :bar/y 2}
and then it tries to eval clojure.core/x
but for rewrite-clj only the read-phase is relevant
(def x #:clojure.core {*clojure-version* 1 :bar/y 2})
(keys x)
;; => ({:major 1, :minor 10, :incremental 1, :qualifier nil} :bar/y)
makes sense
ya, I’m getting it, I think.
thanks for the ping and the help in understanding!
:thumbsup: