This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-09
Channels
- # adventofcode (197)
- # announcements (25)
- # aws (1)
- # babashka (21)
- # beginners (138)
- # calva (21)
- # cider (5)
- # clara (1)
- # clj-kondo (35)
- # clojure (97)
- # clojure-australia (4)
- # clojure-dev (37)
- # clojure-europe (100)
- # clojure-nl (2)
- # clojure-spec (7)
- # clojure-uk (36)
- # clojurescript (11)
- # conjure (15)
- # cursive (20)
- # datomic (12)
- # emacs (10)
- # events (2)
- # fulcro (83)
- # graalvm (14)
- # jobs (1)
- # jobs-discuss (27)
- # kaocha (75)
- # lambdaisland (21)
- # off-topic (27)
- # pedestal (5)
- # reitit (2)
- # reveal (20)
- # rewrite-clj (24)
- # sql (9)
- # tools-deps (37)
- # xtdb (93)
@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}
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.
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)
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