<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged autoresolved</title>
<link>https://ask.clojure.org/index.php/tag/autoresolved</link>
<description></description>
<item>
<title>How to read namespaced keywords with clojure.tools.reader/read?</title>
<link>https://ask.clojure.org/index.php/8856/how-read-namespaced-keywords-with-clojure-tools-reader-read</link>
<description>&lt;p&gt;I'm using clojure.tools.reader/read for reading clojure and cljs  forms from files.&lt;/p&gt;
&lt;p&gt;Everything works fine but reading namespaced keywords like &lt;code&gt;::keyword&lt;/code&gt; get read as :user/keyword. &lt;/p&gt;
&lt;p&gt;I know the reader uses &lt;em&gt;ns&lt;/em&gt; dynamic var to figure out the current namespace for reading symbols and keywords but I don't know how to use it to read a non existing namespace, like the one from the file I'm just reading.&lt;/p&gt;
&lt;p&gt;I'm trying a (in-ns file-ns-symbol) before doing the read so it creates the ns before reading and it works but sometimes I'm getting &lt;code&gt;java.lang.IllegalStateException: Can't change/establish root binding of: *ns* with set&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Just doing &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(binding [*ns* file-ns-symbol]
  (reader/read ...))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;doesn't work since it will try to call (the-ns file-ns-symbol) for a ns that doesn't exist.&lt;/p&gt;
&lt;p&gt;Any ideas or pointers on how to do this?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description>
<category>tools.reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8856/how-read-namespaced-keywords-with-clojure-tools-reader-read</guid>
<pubDate>Mon, 18 Nov 2019 14:04:04 +0000</pubDate>
</item>
</channel>
</rss>