Welcome! Please see the About page for a little more info on how this works.

+4 votes
in Docs by
closed by

In the section for namespaced map syntax, the middle bullet point mentions that :_/foo will treat the keyword as not having the map's current namespace, allowing for including un-namespaced keys in a namespaced map. The example given doesn't include this behavior, which has lead many (me, the entirety of the Discljord server, and I suspect many more in the wider clojure world) to not know about this behavior.

I think it would be helpful to include it in the example, making the behavior explicit and obvious. Something like:

For example, the following map literal with namespace syntax:

#:person{:_/species "Human"
         :first "Han"
         :last "Solo"
         :ship #:ship{:name "Millennium Falcon"
                      :model "YT-1300f light freighter"}}

is read as:

{:species "Human"
 :person/first "Han"
 :person/last "Solo"
 :person/ship {:ship/name "Millennium Falcon"
               :ship/model "YT-1300f light freighter"}}

I've signed the CA and can open an PR if it's acceptable.

closed with the note: The guide has been updated

1 Answer

0 votes
by

The reference pages by design do not contain exhaustive sets of feature examples. The goal of the example here is to demonstrate the most common usage of namespace map syntax. So, I don't think we need to add :_/foo to the example here (it would not make sense).

by
I disagree that references shouldn't have comprehensive examples, but I won't belabor it.

Would you accept the addition of this feature to the [Weird Characters](https://clojure.org/guides/weird_characters#_and_namespace_map_syntax) page?
by
Definitely happy to add stuff to guides
by
Cool, I'll write up a PR shortly.
...