As an aside, note that the part of such a keyword that is often called a "namespace" need not be an existing namespace at all. The official Clojure documentation (e.g. on this page https://clojure.org/reference/reader ) calls them qualified keywords, and the part before the '/' in the keyword name is the qualifier.
One reason for this is that while the qualifier is allowed to be the same as a namespace in your program, it need not be a namespace at all.
In Clojure/Java, all keywords are 'interned' when read or created dynamically at run time, meaning that all keywords with the same name are the same identical Java object in memory. To implement this, all keywords are stored in a common table. You can see this in the Java file Keyword.java
in the Clojure implementation, named table
. It is declared private, and has no public methods to access it except via intern
to create a new keyword, and find
to see whether a keyword with a particular name has already been created.
It is fairly straightforward to use Java reflection APIs to bypass the private
restriction, unless your JVM was started with security options that prevent this. One could use those methods to access the contents of that private table
field, iterate through all of its entries, and return them all, then you could use Clojure or Java code to filter through them and keep only the ones you are interested in.
I do not know enough about the ClojureScript implementation of keywords to say what is possible there.