I've noticed a few folks learning clojure that got tripped up on the namespace maps syntax (eg. #:foo{:bar 42} , https://clojurians.slack.com/archives/C053AK3F9/p1719000006167789). It took me a while to find any docs on it and I'm already familiar with the syntax (searching for "namespace map" or "#:" didn't work). I found mentions at https://www.clojure.org/guides/weird_characters#_and_namespace_map_syntax and https://clojure.org/reference/reader#map_namespace_syntax which seem helpful.
• Maybe there are a few other places where it would be helpful to add a link or mention?
• Maybe https://www.clojure.org/guides/learn/syntax should mention it?
I rarely use them and I get weirded out when I see them. It's not something I would even think to teach.
I think ChatGPT didn't know about them because they're relatively new. And they often don't come up in the scale of problem you would blog about.
I think seeing #:foo{:bar 42 :quux 13} is very different from seeing {:foo/bar 42 :foo/quux 13} so I can understand beginners going "whoa! what is that weird syntax?" -- but I think qualified keywords should be considered a "basic" Clojure idiom and I think it's unfortunate that the default REPL behavior is the shorthand reader syntax when all the qualifiers are the same 😕
There's definitely an opportunity to improve our "getting started" documentation around hash maps. I'm going to create a ticket against http://clojure-doc.org to figure out how to introduce them early and explain the shorthand syntax and the *print-namespace-maps* thing...
It is already mentioned in the Clojure cheatsheet, I see: https://clojure.org/api/cheatsheet
That makes sense since namespaced keywords are also probably unfamiliar syntax on top of the idea of keywords on top of the concept of namespaced keywords.
I really wish there was a global way to turn them off...
I can't tell if that's sarcasm, but (set! *print-namespace-maps* false) should work in the repl.
I mean system global, something in ~/.clojure or an env var. I guess I could add this to launchpad.
It's set by the repl, so you should be able to use middleware or tweak your dev setup to set a different value.