<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged data readers</title>
<link>https://ask.clojure.org/index.php/tag/data%20readers</link>
<description>Powered by Question2Answer</description>
<item>
<title>Should Clojure automatically load namespaces of vars defined in data_readers.clj?</title>
<link>https://ask.clojure.org/index.php/11286/should-clojure-automatically-namespaces-defined-datareaders</link>
<description>&lt;p&gt;I thought Clojure automatically loads namespaces for vars used to read tagged literals in the source code, but apparently it isn&#039;t.&lt;/p&gt;
&lt;p&gt;Given a library that defines data_readers.clj with following content:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{foo/bar my.library.foo/bar
 foo/baz my.library/baz}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;An attempt to read &lt;code&gt;#foo/bar [1 2 3]&lt;/code&gt; will result in this exception:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Syntax error reading source at (REPL:1:69).
Attempting to call unbound fn: #&#039;my.library.foo/bar
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To avoid this exception you need to &lt;code&gt;require&lt;/code&gt; the library namespace before using reader tags. &lt;/p&gt;
&lt;p&gt;It would be more convenient to be able to use library reader tags just by adding it to the classpath without explicit require step. &lt;/p&gt;
&lt;p&gt;I don&#039;t know why it&#039;s made this way... &lt;/p&gt;
&lt;p&gt;If the reasoning is clojure.core startup time, perhaps the actual load of the var ns might happen at the first tagged literal read time?&lt;br&gt;
If the reasoning is security implications of unexpected code execution, maybe the behavior of requiring data reader namespaces could be configured with &lt;code&gt;*read-eval*&lt;/code&gt;?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11286/should-clojure-automatically-namespaces-defined-datareaders</guid>
<pubDate>Mon, 22 Nov 2021 14:29:20 +0000</pubDate>
</item>
</channel>
</rss>