﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions and answers in Syntax and reader</title>
<link>https://ask.clojure.org/index.php/qa/clojure/reader</link>
<description></description>
<item>
<title>Answered: `eval` using functions with metadata</title>
<link>https://ask.clojure.org/index.php/15115/eval-using-functions-with-metadata?show=15116#a15116</link>
<description>&lt;p&gt;You're eval'ing + to a function object there when it seems like you should be staying in symbol land:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (eval (list (with-meta '+ {}) 1 2))
3
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A function object itself is not Clojure data (other than opaquely as an object). When working symbolically, you should stay in symbols.&lt;/p&gt;
&lt;p&gt;There are some places where the compiler uses an escape hatch of print + read-eval (&lt;code&gt;#=&lt;/code&gt;) to recover custom types (sorted maps and sets), but I'd consider that implementation details, not something you as a user should be doing generally.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15115/eval-using-functions-with-metadata?show=15116#a15116</guid>
<pubDate>Mon, 01 Jun 2026 16:31:28 +0000</pubDate>
</item>
<item>
<title>Answered: Literals for Unicode code points (and perhaps also sequences thereof)</title>
<link>https://ask.clojure.org/index.php/14875/literals-unicode-code-points-perhaps-also-sequences-thereof?show=14886#a14886</link>
<description>&lt;p&gt;Created feature request jira &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2935&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2935&lt;/a&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14875/literals-unicode-code-points-perhaps-also-sequences-thereof?show=14886#a14886</guid>
<pubDate>Mon, 12 Jan 2026 22:26:24 +0000</pubDate>
</item>
<item>
<title>Octal escape sequence decoding in strings does not stop at non-octal digit</title>
<link>https://ask.clojure.org/index.php/14846/octal-escape-sequence-decoding-strings-does-stop-octal-digit</link>
<description>&lt;p&gt;Strings suppose to support standard Java escape sequences, including octal escape sequence: [0-7]{1,3} &lt;/p&gt;
&lt;p&gt;In Java decoding of octal sequences stop at the first non-octal digit or any other character if there are 1 or two octal digits in the escape sequence. For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jshell&amp;gt; &quot;\18&quot;
$1 ==&amp;gt; &quot;\0018&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But Clojure reads up to 3 potentially octal digits greedily resulting in wrongly consuming non-octal digits:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.4
user=&amp;gt; &quot;\18&quot;
Syntax error reading source at (REPL:1:5).
Invalid digit: 8
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;non-octal characters:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.4
user=&amp;gt; &quot;\1d&quot;
Syntax error reading source at (REPL:1:5).
Invalid digit: d
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And succeed only when there is line terminator or exact three octal digits in supported octal range:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.4
user=&amp;gt; &quot;\1&quot;
&quot;&quot;
user=&amp;gt; &quot;\1&quot;
&quot;&quot;
user=&amp;gt; &quot;\12&quot;
&quot;\n&quot;
user=&amp;gt; &quot;\123&quot;
&quot;S&quot;
user=&amp;gt; &quot;\123d&quot;
&quot;Sd&quot;
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14846/octal-escape-sequence-decoding-strings-does-stop-octal-digit</guid>
<pubDate>Thu, 18 Dec 2025 09:35:53 +0000</pubDate>
</item>
<item>
<title>Answered: [clojure.edn] Leading zeros in numbers</title>
<link>https://ask.clojure.org/index.php/14798/clojure-edn-leading-zeros-in-numbers?show=14842#a14842</link>
<description>&lt;p&gt;Leading zeroes in Clojure should largely follow the lead of Java when the reference is unclear:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Long - multiple leading 0s allowed, treated as octal&lt;/li&gt;
&lt;li&gt;BigInteger - multiple leading 0s allowed, treated as decimal in Java BigInteger, octal in Clojure (this is a difference, but supported by the reader reference page)&lt;/li&gt;
&lt;li&gt;Double - multiple leading 0s allowed in either whole number part of exponent, treated as decimal &lt;/li&gt;
&lt;li&gt;BigDecimal - multiple leading 0s allowed, treated as decimal&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With respect to edn, there are additional constraints - octal is not supported, and leading 0s not allowed in integers, but are allowed in decimal whole and exponents by my reading. I do not see support for your assertion &quot;even for floats&quot; - the constraint is listed only for integers). &lt;/p&gt;
&lt;p&gt;Thus I would expect that any leading 0s in an integer (with or without N suffix) should be invalid, yet they are all read as octal. So that seems like a potential bug. Because clojure.edn is a superset of edn, you could potentially contend this is additive syntax/semantics beyond edn but seems a little confusing.&lt;/p&gt;
&lt;p&gt;For floating points, by my reading, leading 0s in whole or exponent parts are allowed, so no issue or difference from Clojure or Java there afaict.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14798/clojure-edn-leading-zeros-in-numbers?show=14842#a14842</guid>
<pubDate>Mon, 15 Dec 2025 20:05:17 +0000</pubDate>
</item>
<item>
<title>Answered: Aliased namespace in tagged literal</title>
<link>https://ask.clojure.org/index.php/14829/aliased-namespace-in-tagged-literal?show=14830#a14830</link>
<description>&lt;p&gt;Logged as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2932&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2932&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I reworded the title and problem as this slips into solution space (and I'm not sure that solution is even possible given the reader nature of the problem).&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14829/aliased-namespace-in-tagged-literal?show=14830#a14830</guid>
<pubDate>Thu, 11 Dec 2025 20:18:34 +0000</pubDate>
</item>
<item>
<title>Answered: clojure.edn and clojure allows keywords with empty (&quot;&quot;) namespaces</title>
<link>https://ask.clojure.org/index.php/14811/clojure-edn-clojure-allows-keywords-with-empty-namespaces?show=14824#a14824</link>
<description>&lt;p&gt;Logged as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2931&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2931&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Other old and related JIRAs for relevance: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-1286&quot;&gt;CLJ-1286&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-1252&quot;&gt;CLJ-1252&lt;/a&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14811/clojure-edn-clojure-allows-keywords-with-empty-namespaces?show=14824#a14824</guid>
<pubDate>Tue, 09 Dec 2025 22:55:20 +0000</pubDate>
</item>
<item>
<title>Answered: Double colon (&quot;::&quot;) in the middle or at the end of identifier.</title>
<link>https://ask.clojure.org/index.php/14787/double-colon-in-the-middle-or-at-the-end-of-identifier?show=14793#a14793</link>
<description>&lt;p&gt;Don't know, sorry.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14787/double-colon-in-the-middle-or-at-the-end-of-identifier?show=14793#a14793</guid>
<pubDate>Tue, 02 Dec 2025 16:47:37 +0000</pubDate>
</item>
<item>
<title>Answered: Support characters beyond basic multilingual plane</title>
<link>https://ask.clojure.org/index.php/14790/support-characters-beyond-basic-multilingual-plane?show=14791#a14791</link>
<description>&lt;p&gt;That line you linked is specifically for reading an individual character value (like &lt;code&gt;\a&lt;/code&gt;) - as a single character it's not possible to represent both parts of a surrogate pair, so this seems correct (a Java char is an int).&lt;/p&gt;
&lt;p&gt;However, you can use surrogate pairs in strings, which is how you would most commonly use them, and that works fine.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$  clj
Clojure 1.12.3
user=&amp;gt; &quot;\ud83d\ude0d&quot;
&quot;&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I believe surrogate pairs are not currently allowed in symbols or keywords, that's maybe something that could be extended in the future, but I haven't seen anyone looking for that yet.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14790/support-characters-beyond-basic-multilingual-plane?show=14791#a14791</guid>
<pubDate>Tue, 02 Dec 2025 16:42:47 +0000</pubDate>
</item>
<item>
<title>Answered: clojure.edn/read invoke user-supplied reader functions when tagged literal is to be discarded by discard macro</title>
<link>https://ask.clojure.org/index.php/14761/clojure-supplied-functions-tagged-literal-discarded-discard?show=14775#a14775</link>
<description>&lt;p&gt;This is definitely an appropriate thing to put on Ask Clojure and seems like a bug in the impl of the spec to me.&lt;/p&gt;
&lt;p&gt;Logged as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2928&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2928&lt;/a&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14761/clojure-supplied-functions-tagged-literal-discarded-discard?show=14775#a14775</guid>
<pubDate>Tue, 25 Nov 2025 20:22:21 +0000</pubDate>
</item>
<item>
<title>Answered: Inconsistent errors in ratio parsing with either `clojure.edn/read` or `clojure.core/read`</title>
<link>https://ask.clojure.org/index.php/14763/inconsistent-errors-ratio-parsing-either-clojure-clojure?show=14772#a14772</link>
<description>&lt;p&gt;Ratios in Clojure are rational ratios with integer numerator and denominator. Ratio syntax is not a composite of integer or other numeric syntaxes, it is its own definition where the numerator and denominator are strings of digits of arbitrary length (treated as long or biginteger as necessary based on scale).&lt;/p&gt;
&lt;p&gt;The syntax is semantically defined as: &lt;br&gt;
 &lt;code&gt;sign? digit+ '/' digit+&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The regex pattern is currently:&lt;br&gt;
&lt;code&gt;&quot;([-+]?[0-9]+)/([0-9]+)&quot;&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This pattern incorrectly allows leading 0 and should be narrowed.&lt;/p&gt;
&lt;p&gt;Filed jira at &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2925&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2925&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The other errors are expected and these syntaxes are not supported.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14763/inconsistent-errors-ratio-parsing-either-clojure-clojure?show=14772#a14772</guid>
<pubDate>Tue, 25 Nov 2025 19:43:36 +0000</pubDate>
</item>
<item>
<title>Answered: Do you use arity 3 or higher comparisons such as = &lt; &lt;= &gt; &gt;= == in performance sensitive code?</title>
<link>https://ask.clojure.org/index.php/13627/arity-higher-comparisons-such-performance-sensitive-code?show=14681#a14681</link>
<description>&lt;p&gt;Yes, I use 3-arity inequality functions with some regularity, much like PostgreSQL's &lt;code&gt;BETWEEN&lt;/code&gt; operator, I've also seen it used by others. I think the most frequent use case for this is in tests for me personally but some of these are inside &lt;code&gt;are&lt;/code&gt;s that can get large, so I would appreciate a performance optimization.&lt;/p&gt;
&lt;p&gt;I would also agree that 4+ arity is exponentially rarer than 3-arity (I've never seen it in practice, but I assume there's been at least one person who has done &lt;code&gt;(apply &amp;gt; coll)&lt;/code&gt; at some point to check if a collection is sorted), but I have no data on this beyond anecdotal experience.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13627/arity-higher-comparisons-such-performance-sensitive-code?show=14681#a14681</guid>
<pubDate>Tue, 12 Aug 2025 21:31:07 +0000</pubDate>
</item>
<item>
<title>Answered: .pow bigdec vs bigint</title>
<link>https://ask.clojure.org/index.php/14640/pow-bigdec-vs-bigint?show=14642#a14642</link>
<description>&lt;p&gt;Per the &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/data_structures#_bigint_and_bigdecimal_literals&quot;&gt;reference&lt;/a&gt;, the Clojure bigint type is clojure.lang.BigInt, which is like java.math.BigInteger but optimized for ops in the long range. Because there are lots of ways you can end up with java.lang.BigInt, both are supported in lots of places. If you're going after specific interop on the type, you'll need to confine yourself to clojure BigInt or else use biginteger to get to java BigInteger.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14640/pow-bigdec-vs-bigint?show=14642#a14642</guid>
<pubDate>Sat, 26 Jul 2025 18:51:35 +0000</pubDate>
</item>
<item>
<title>Associative destructuring with if-let</title>
<link>https://ask.clojure.org/index.php/14574/associative-destructuring-with-if-let</link>
<description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I'm surprised by the result of this code :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(if-let [{errors :errors} {}]
    errors
    true) =&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I would have expected the result to be 'true'.&lt;/p&gt;
&lt;p&gt;As indicated by the result, 'errors' evaluates to nil, but still it's the 'then' arm of the 'if' that is evaluated.&lt;/p&gt;
&lt;p&gt;The guide on destructuring state that &quot;You can utilize destructuring anywhere that there is an explicit or implicit let binding.&quot;, so I'm a bit puzzled.&lt;/p&gt;
&lt;p&gt;Please, enlighten me. Thanks !&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14574/associative-destructuring-with-if-let</guid>
<pubDate>Sat, 07 Jun 2025 17:21:45 +0000</pubDate>
</item>
<item>
<title>Answered: clojure.edn parser will not parse complete file in some cases</title>
<link>https://ask.clojure.org/index.php/14537/clojure-edn-parser-will-not-parse-complete-file-in-some-cases?show=14538#a14538</link>
<description>&lt;p&gt;It's by design, all according to the docstring of &lt;code&gt;edn/read&lt;/code&gt;:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Reads the next object from stream [...]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;You can read multiple times from the same stream to get all of the objects and to validate the whole file.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(with-open [r (io/reader &quot;demo.edn&quot;)]
  (loop []
    (let [data (edn/read (java.io.PushbackReader. r))]
      (println &quot;Got data&quot; data)
      (recur))))
Got data {:foo 1, :bar 2}
Got data :baz
Got data 3
Execution error at user/eval3609 (form-init10153318817371430115.clj:3).
Unmatched delimiter: }
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14537/clojure-edn-parser-will-not-parse-complete-file-in-some-cases?show=14538#a14538</guid>
<pubDate>Wed, 07 May 2025 12:52:47 +0000</pubDate>
</item>
<item>
<title>Answered: Symbols with leading slashes</title>
<link>https://ask.clojure.org/index.php/14506/symbols-with-leading-slashes?show=14508#a14508</link>
<description>&lt;p&gt;There are no plans to widen what is allowed in symbols.&lt;/p&gt;
&lt;p&gt;The &lt;code&gt;symbol&lt;/code&gt; function supports things wider than the spec for the same reasons &lt;code&gt;keyword&lt;/code&gt; does which are outlined at &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/guides/faq#unreadable_keywords&quot;&gt;https://clojure.org/guides/faq#unreadable_keywords&lt;/a&gt; - in short, programatic use and performance.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14506/symbols-with-leading-slashes?show=14508#a14508</guid>
<pubDate>Thu, 17 Apr 2025 14:39:40 +0000</pubDate>
</item>
<item>
<title>Answered: Consider postponing setting the default values of destructured map keys that might rely on other keys</title>
<link>https://ask.clojure.org/index.php/14478/consider-postponing-setting-default-values-destructured?show=14483#a14483</link>
<description>&lt;p&gt;The intent of :or is to provide a default value for missing values, not to provide an arbitrary expression over things that are in the process of being bound by the destructuring itself. This is not a feature we want to support.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14478/consider-postponing-setting-default-values-destructured?show=14483#a14483</guid>
<pubDate>Fri, 28 Mar 2025 15:29:28 +0000</pubDate>
</item>
<item>
<title>Answered: Add digit separators support to number literals.</title>
<link>https://ask.clojure.org/index.php/8511/add-digit-separators-support-to-number-literals?show=14220#a14220</link>
<description>&lt;p&gt;Not sure it's a good idea, but here's a macro that you can try without having to change the language.  You would have to wrap the underbar literals in an (und ...) macro call.  Also, note that the most convenient style requires a leading _ on the (fake) symbol notation.  Or you can use a (questionable) keyword or a string.  A legal number should also work just for completeness.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defmacro und [lit]
  (if-let [s# (if (string? lit) lit (when (instance? clojure.lang.Named lit) (name lit)))]
    `~(clojure.edn/read-string (clojure.string/replace s# &quot;_&quot; &quot;&quot;))
    lit))

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;;;; valid uses returning 123456&lt;br&gt;
;;; note: bare symbol style must start with _&lt;br&gt;
(und 123456)&lt;br&gt;
(und _123_456)&lt;br&gt;
(und :123_456)&lt;br&gt;
(und &quot;123_456&quot;)&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8511/add-digit-separators-support-to-number-literals?show=14220#a14220</guid>
<pubDate>Fri, 01 Nov 2024 19:09:36 +0000</pubDate>
</item>
<item>
<title>Answered: Can Clojure support a byte-array literal?</title>
<link>https://ask.clojure.org/index.php/13534/can-clojure-support-a-byte-array-literal?show=13537#a13537</link>
<description>&lt;p&gt;Unless I'm missing something, three years ago you have asked the same exact thing: &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/9567/possible-create-tagged-literal-reader-for-clojure-core-vec&quot;&gt;https://ask.clojure.org/index.php/9567/possible-create-tagged-literal-reader-for-clojure-core-vec&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Why create a new post? It'll only end up spreading the already thin attention this issue has. That's why posts here have votes.&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Am I missing something, or is this simply not possible? And if it's not possible, could such support be added?&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Given that that other question has only one vote in 3 years, I'd say not that many people care for the maintainers to put it high enough in the priority list.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13534/can-clojure-support-a-byte-array-literal?show=13537#a13537</guid>
<pubDate>Sun, 10 Dec 2023 10:30:31 +0000</pubDate>
</item>
<item>
<title>Answered: Clojure reader fails to suppress cljs namespaced keywords</title>
<link>https://ask.clojure.org/index.php/13422/clojure-reader-fails-to-suppress-cljs-namespaced-keywords?show=13423#a13423</link>
<description>&lt;p&gt;Autoresolved keywords require namespace resolution (the main feature of the reader that requires external environment). &lt;/p&gt;
&lt;p&gt;Because reader conditionals &quot;read&quot; all of the parts of the conditional, it is necessary that anything in the conditional is readable in every platform, and thus autoresolved keywords in reader conditionals should not rely on conditional namespaces.&lt;/p&gt;
&lt;p&gt;This should be considered the expected behavior, so don't do that.&lt;/p&gt;
&lt;p&gt;We have considered whether it would be possible to suspend autoresolved keyword resolution in the context of reader conditionals but it is somewhat tricky, and I don't think we're going to do that anytime soon.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13422/clojure-reader-fails-to-suppress-cljs-namespaced-keywords?show=13423#a13423</guid>
<pubDate>Fri, 03 Nov 2023 21:37:59 +0000</pubDate>
</item>
<item>
<title>Answered: Location data on all IObj</title>
<link>https://ask.clojure.org/index.php/13314/location-data-on-all-iobj?show=13315#a13315</link>
<description>&lt;p&gt;What problem are you trying to solve?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13314/location-data-on-all-iobj?show=13315#a13315</guid>
<pubDate>Thu, 21 Sep 2023 11:11:07 +0000</pubDate>
</item>
<item>
<title>Answered: Why can't unknown tagged literals be embedded in expressions when `*default-data-reader-fn*` is set to `tagged-literal`?</title>
<link>https://ask.clojure.org/index.php/13274/unknown-tagged-literals-embedded-expressions-default-literal?show=13287#a13287</link>
<description>&lt;p&gt;Yes, it should, logged as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2801&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2801&lt;/a&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13274/unknown-tagged-literals-embedded-expressions-default-literal?show=13287#a13287</guid>
<pubDate>Thu, 14 Sep 2023 14:52:30 +0000</pubDate>
</item>
<item>
<title>Answered: should `clojure.core/=` have a zero arity?</title>
<link>https://ask.clojure.org/index.php/12441/should-clojure-core-have-a-zero-arity?show=12614#a12614</link>
<description>&lt;p&gt;What does it mean to compare 0 things?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12441/should-clojure-core-have-a-zero-arity?show=12614#a12614</guid>
<pubDate>Mon, 30 Jan 2023 20:00:23 +0000</pubDate>
</item>
<item>
<title>Answered: Numeric keywords work but not numeric names in qualified keywords?</title>
<link>https://ask.clojure.org/index.php/12591/numeric-keywords-work-but-numeric-names-qualified-keywords?show=12608#a12608</link>
<description>&lt;p&gt;See &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/guides/faq#keyword_number&quot;&gt;https://clojure.org/guides/faq#keyword_number&lt;/a&gt; for more info&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12591/numeric-keywords-work-but-numeric-names-qualified-keywords?show=12608#a12608</guid>
<pubDate>Mon, 30 Jan 2023 19:46:34 +0000</pubDate>
</item>
<item>
<title>Answered: How to put the records of my file into a defined list and use it after in my code?</title>
<link>https://ask.clojure.org/index.php/12444/how-put-the-records-file-into-defined-list-and-use-after-code?show=12445#a12445</link>
<description>&lt;p&gt;So, I think the main thing here is that &lt;code&gt;doseq&lt;/code&gt; returns &lt;code&gt;nil&lt;/code&gt;, not a list.&lt;/p&gt;
&lt;p&gt;Perhaps something like this will get you started...&lt;/p&gt;
&lt;p&gt;&lt;code&gt;file.txt:&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1|Xxx|info1|222-2222
2|Yyy|info2|333-3333
3|Zzz|info3|444-4444
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Then, in the REPL:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (defn load-data
        [filename]
        (with-open [r (clojure.java.io/reader filename)]
          (-&amp;gt; (for [line (line-seq r)]
                (let [[id name info phone] (clojure.string/split line #&quot;\|&quot;)]
                  [(Integer/parseInt id) name info phone]))
              (doall))))
#'user/load-data
user&amp;gt; (load-data &quot;file.txt&quot;)
([1 &quot;Xxx&quot; &quot;info1&quot; &quot;222-2222&quot;]
 [2 &quot;Yyy&quot; &quot;info2&quot; &quot;333-3333&quot;]
 [3 &quot;Zzz&quot; &quot;info3&quot; &quot;444-4444&quot;])
&lt;/code&gt;&lt;/pre&gt;
&lt;hr&gt;
&lt;p&gt;Notably, the &lt;code&gt;doall&lt;/code&gt; is necessary here, since &lt;code&gt;for&lt;/code&gt; returns a lazy sequence; without the &lt;code&gt;doall&lt;/code&gt;, &lt;code&gt;with-open&lt;/code&gt; will close the reader before anything is read.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12444/how-put-the-records-file-into-defined-list-and-use-after-code?show=12445#a12445</guid>
<pubDate>Thu, 08 Dec 2022 23:32:37 +0000</pubDate>
</item>
<item>
<title>Answered: Complete beginner - questions about formatting, structure etc...</title>
<link>https://ask.clojure.org/index.php/12418/complete-beginner-questions-about-formatting-structure-etc?show=12443#a12443</link>
<description>&lt;p&gt;On the subject of formatting and idioms, you may find the unofficial community &lt;a rel=&quot;nofollow&quot; href=&quot;https://guide.clojure.style/&quot;&gt;https://guide.clojure.style/&lt;/a&gt; helpful.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12418/complete-beginner-questions-about-formatting-structure-etc?show=12443#a12443</guid>
<pubDate>Thu, 08 Dec 2022 18:30:10 +0000</pubDate>
</item>
<item>
<title>Answered: Suggestion: allow docstrings in defonce like in def</title>
<link>https://ask.clojure.org/index.php/12341/suggestion-allow-docstrings-in-defonce-like-in-def?show=12343#a12343</link>
<description>&lt;p&gt;We have an old ticket for this that has been through several rounds  of patches, it's actually surprisingly tricky to get right. :)&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-1148&quot;&gt;https://clojure.atlassian.net/browse/CLJ-1148&lt;/a&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12341/suggestion-allow-docstrings-in-defonce-like-in-def?show=12343#a12343</guid>
<pubDate>Sun, 30 Oct 2022 16:01:41 +0000</pubDate>
</item>
<item>
<title>Answered: Read-time evaluation of macros causes errors</title>
<link>https://ask.clojure.org/index.php/12296/read-time-evaluation-of-macros-causes-errors?show=12299#a12299</link>
<description>&lt;p&gt;Read-eval is not a public feature and generally you should not use it. This is a big (and intentional) difference from Common Lisp. It is primarily used internally in some corner cases to read forms that reconstruct Java objects that lack print forms.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12296/read-time-evaluation-of-macros-causes-errors?show=12299#a12299</guid>
<pubDate>Tue, 11 Oct 2022 19:26:05 +0000</pubDate>
</item>
<item>
<title>Answered: improve syntax errors on tagged-literals</title>
<link>https://ask.clojure.org/index.php/12256/improve-syntax-errors-on-tagged-literals?show=12260#a12260</link>
<description>&lt;p&gt;Logged as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2726&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2726&lt;/a&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12256/improve-syntax-errors-on-tagged-literals?show=12260#a12260</guid>
<pubDate>Thu, 29 Sep 2022 19:14:18 +0000</pubDate>
</item>
<item>
<title>Answered: Why i get the &quot;Could not locate hugsql/core__init.class, hugsql/core.clj or hugsql/core.cljc on classpath.&quot; ?</title>
<link>https://ask.clojure.org/index.php/12240/could-locate-hugsql-coreinit-class-hugsql-hugsql-classpath?show=12243#a12243</link>
<description>&lt;p&gt;Oh i'm sorry i think i've already get the solution. After i restart the nREPL, eveything is running normaly.&lt;br&gt;
But need to change some of the code. &lt;/p&gt;
&lt;p&gt;From &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(hugsql/def-db-fns &quot;resources/users.sql&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;to&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(hugsql/def-db-fns &quot;users.sql&quot;)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12240/could-locate-hugsql-coreinit-class-hugsql-hugsql-classpath?show=12243#a12243</guid>
<pubDate>Mon, 26 Sep 2022 17:54:47 +0000</pubDate>
</item>
<item>
<title>Answered: Behaviour of for is different when loading a file versus typing in the REPL</title>
<link>https://ask.clojure.org/index.php/12014/behaviour-for-different-when-loading-file-versus-typing-repl?show=12016#a12016</link>
<description>&lt;p&gt;According to the docs (&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/map&quot;&gt;https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/map&lt;/a&gt;), map returns a lazy sequence, which means the work is not done (in particular the prn's do not happen) until the sequence is consumed. As Eugene Pakhomov points out in another answer, the REPL consumes the sequence, but the forms in the file by themselves did not. &lt;/p&gt;
&lt;p&gt;Because map returns a lazy sequence, one does not usually rely on map for side effects like printing.  doseq is good for executing side effects.  Besides the question of timing, you usually need &lt;em&gt;either&lt;/em&gt; the data (sequence) &lt;em&gt;or&lt;/em&gt; the side effects, so it is convenient that doseq does not amass a sequence. &lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12014/behaviour-for-different-when-loading-file-versus-typing-repl?show=12016#a12016</guid>
<pubDate>Sat, 25 Jun 2022 10:40:53 +0000</pubDate>
</item>
<item>
<title>Answered: Has middle of sequence &amp;rest destructuring been considered?</title>
<link>https://ask.clojure.org/index.php/11985/has-middle-of-sequence-rest-destructuring-been-considered?show=11986#a11986</link>
<description>&lt;p&gt;In what scenario would this be useful?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11985/has-middle-of-sequence-rest-destructuring-been-considered?show=11986#a11986</guid>
<pubDate>Mon, 20 Jun 2022 17:54:27 +0000</pubDate>
</item>
<item>
<title>Answered: Why i get different result on the same sequence?</title>
<link>https://ask.clojure.org/index.php/11957/why-i-get-different-result-on-the-same-sequence?show=11959#a11959</link>
<description>&lt;p&gt;Let's take a look at what &lt;code&gt;clojure.string/includes?&lt;/code&gt; says it does and how it is implemented:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (doc clojure.string/includes?)
-------------------------
clojure.string/includes?
([s substr])
  True if s includes substr.
nil
user=&amp;gt; (source clojure.string/includes?)
(defn includes?
  &quot;True if s includes substr.&quot;
  {:added &quot;1.8&quot;}
  [^CharSequence s ^CharSequence substr]
  (.contains (.toString s) substr))
nil
user=&amp;gt; (.toString (map :name [{:name &quot;One&quot;} {:name &quot;Two&quot;}]))
&quot;clojure.lang.LazySeq@26e067&quot;
user=&amp;gt; (.toString [&quot;One&quot; &quot;Two&quot;])
&quot;[\&quot;One\&quot; \&quot;Two\&quot;]&quot;
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;We see that it assumes its first argument is a string -- or more specifically a &lt;code&gt;CharSequence&lt;/code&gt; -- and it starts out by calling &lt;code&gt;.toString&lt;/code&gt; on that argument.&lt;/p&gt;
&lt;p&gt;We see that &lt;code&gt;(.toString (map .. ..))&lt;/code&gt; produces a cryptic-looking string but this is because &lt;code&gt;map&lt;/code&gt; produces a lazy sequence and the default string representation of a lazy sequence is its type and a hex value, like any Java object that doesn't have a specific string representation.&lt;/p&gt;
&lt;p&gt;However, calling &lt;code&gt;.toString&lt;/code&gt; on a quoted list or a vector produces a string representation of the elements of the list or vector.&lt;/p&gt;
&lt;p&gt;Consequently, &lt;code&gt;clojure.string/includes?&lt;/code&gt; &quot;works&quot; in the latter case because even though you are not passing it a &lt;code&gt;CharSequence&lt;/code&gt;, when it converts the data structure to a string, it includes the name you are looking for.&lt;/p&gt;
&lt;p&gt;Since you want to check if any element of the sequence contains the string, what you probably want here is:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(some #(clojure.string/includes? % &quot;Joni&quot;) (map :name (mapify ..)))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11957/why-i-get-different-result-on-the-same-sequence?show=11959#a11959</guid>
<pubDate>Tue, 14 Jun 2022 05:54:18 +0000</pubDate>
</item>
<item>
<title>Answered: atom value different results</title>
<link>https://ask.clojure.org/index.php/11941/atom-value-different-results?show=11942#a11942</link>
<description>&lt;p&gt;My first guess would be for's laziness. Try (def cnt' (vec (for[i (range 5)] (shift-by i)))) and see if that changes things.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11941/atom-value-different-results?show=11942#a11942</guid>
<pubDate>Fri, 03 Jun 2022 21:09:12 +0000</pubDate>
</item>
<item>
<title>Answered: What is the difference between &quot;keyword&quot; and &quot;atom&quot;?</title>
<link>https://ask.clojure.org/index.php/11792/what-is-the-difference-between-keyword-and-atom?show=11798#a11798</link>
<description>&lt;p&gt;Ignoring atoms completely, here's an informal perspective on keywords:&lt;/p&gt;
&lt;p&gt;I like to think of keywords conceptually like a string/symbol hybrid with special superpowers. Like symbols, they're restricted to certain characters (notably, no spaces allowed) and can be namespaced: &lt;code&gt;:myproject.api/foo&lt;/code&gt;. Like strings, they're really just a data primitive.&lt;/p&gt;
&lt;p&gt;The main keyword superpower is that they can be called as functions to get values out of associative data structures like hash-maps: &lt;code&gt;(:foo {:foo 42 &quot;bar&quot; 36})&lt;/code&gt; =&amp;gt; &lt;code&gt;42&lt;/code&gt; and sets: &lt;code&gt;(:foo #{:foo :bar})&lt;/code&gt; =&amp;gt; &lt;code&gt;:foo&lt;/code&gt;. You can't use strings or numbers as functions.&lt;/p&gt;
&lt;p&gt;Here's a helpful StackOverflow answer about why keywords exist in Clojure: &lt;a rel=&quot;nofollow&quot; href=&quot;https://stackoverflow.com/a/11655615&quot;&gt;https://stackoverflow.com/a/11655615&lt;/a&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11792/what-is-the-difference-between-keyword-and-atom?show=11798#a11798</guid>
<pubDate>Sat, 23 Apr 2022 23:50:34 +0000</pubDate>
</item>
<item>
<title>Answered: java interop, property same name as object</title>
<link>https://ask.clojure.org/index.php/11618/java-interop-property-same-name-as-object?show=11636#a11636</link>
<description>&lt;p&gt;I attempted to reproduce based on the code above and it failed to reproduce&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;% cat A.java
public class A {

public int af() { return 2; }
public int af1(int x) { return x+2; }
public int a = 1;
static public int as;
static public int afs() { return 20; }
static public int afs1(int x) { return x+20; }

}
% javac A.java
% clojure -Scp &quot;.&quot;
Error: Could not find or load main class clojure.main
Caused by: java.lang.ClassNotFoundException: clojure.main
zsh: exit 1     clojure -Scp &quot;.&quot;
% clojure -Sdeps '{:paths [&quot;.&quot;]}'
Clojure 1.10.2
user=&amp;gt; (import A)
A
user=&amp;gt;  (def a (A.))
#'user/a
user=&amp;gt; (def x (A.))
#'user/x
user=&amp;gt; (def a1 (A.))
#'user/a1
user=&amp;gt;  (.a a1)
1
user=&amp;gt; (.a x)
1
user=&amp;gt;  (.a a)
1
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It looks like your &lt;code&gt;clojure&lt;/code&gt; script is not the tools.deps clojure script, since that has no -cp option, what script is it and what else is it doing besides launching clojure? Your repl also doesn't print the version of clojure when you start it, what repl are you using, what version of clojure?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11618/java-interop-property-same-name-as-object?show=11636#a11636</guid>
<pubDate>Tue, 15 Mar 2022 23:43:04 +0000</pubDate>
</item>
<item>
<title>Answered: Why does if-not call not instead of reversing the forms with if?</title>
<link>https://ask.clojure.org/index.php/11507/why-does-if-not-call-not-instead-of-reversing-the-forms-with-if?show=11508#a11508</link>
<description>&lt;p&gt;Logged as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2691&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2691&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This has definitely come up on Slack before, don't know of a jira/ask for it. &lt;/p&gt;
&lt;p&gt;I don't think it's a huge deal, could see it mostly coming up if it blows the inline code size boundary or something like that. Difficult to come up with that case, but maybe it would be amenable to a microbenchmark. If anyone does test it, it's important to check Java 8, 11, 17 - this is exactly the kind of thing the jvm gets better at over time and it could easily be less important on newer jvm.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11507/why-does-if-not-call-not-instead-of-reversing-the-forms-with-if?show=11508#a11508</guid>
<pubDate>Tue, 25 Jan 2022 00:08:29 +0000</pubDate>
</item>
<item>
<title>Answered: 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?show=11289#a11289</link>
<description>&lt;p&gt;It would be great if this behaviour changed or could be configured. &lt;/p&gt;
&lt;p&gt;Currently it's pretty hard to use dev time tools like &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/weavejester/hashp&quot;&gt;hasp&lt;/a&gt; or &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/philoskim/debux&quot;&gt;debux&lt;/a&gt;, since you have to either require them everywhere or use workarounds like &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/gfredericks/user.clj&quot;&gt;user.clj inject&lt;/a&gt; to get the require.&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?show=11289#a11289</guid>
<pubDate>Tue, 23 Nov 2021 10:50:21 +0000</pubDate>
</item>
<item>
<title>Answered: Does the `any?` function have the correct behavior?</title>
<link>https://ask.clojure.org/index.php/11260/does-the-any-function-have-the-correct-behavior?show=11261#a11261</link>
<description>&lt;p&gt;&lt;code&gt;any?&lt;/code&gt; is a predicate that is intended to always return true, so yes it is the correct behavior. &lt;code&gt;any?&lt;/code&gt; was added as a predicate to use with spec in the case where any value is valid. It is not a complement to &lt;code&gt;not-any?&lt;/code&gt;, despite that obvious assumption. There are, in the end, only so many words and despite a lot of care in this regard, there are times when these confusions exist.&lt;/p&gt;
&lt;p&gt;Re &quot;I believe any? should take two arguments and return true if any predicate is true.&quot;, this is similar to &lt;code&gt;and&lt;/code&gt; (for N args) but that does have limits as a macro, or &lt;code&gt;every?&lt;/code&gt; (for a coll), or the higher-order function &lt;code&gt;every-pred&lt;/code&gt; for creating a composite pred. Depending on your case, one of those probably makes sense. &lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11260/does-the-any-function-have-the-correct-behavior?show=11261#a11261</guid>
<pubDate>Tue, 09 Nov 2021 22:39:21 +0000</pubDate>
</item>
<item>
<title>Answered: Are there design considerations behind allowing keywords to be functions, but not strings or numbers?</title>
<link>https://ask.clojure.org/index.php/11025/considerations-allowing-keywords-functions-strings-numbers?show=11026#a11026</link>
<description>&lt;p&gt;&quot;Aside from being unable to extend IFn to strings and numbers&quot; is kind of a critical thing. We don't own the types and adding those checks would have to be in the path of all function evaluation, so I think this is a non-starter.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11025/considerations-allowing-keywords-functions-strings-numbers?show=11026#a11026</guid>
<pubDate>Wed, 08 Sep 2021 21:40:16 +0000</pubDate>
</item>
<item>
<title>Why do some reader tags throw when evaluated on their own?</title>
<link>https://ask.clojure.org/index.php/10945/why-do-some-reader-tags-throw-when-evaluated-on-their-own</link>
<description>&lt;p&gt;For example, take the &lt;code&gt;#ordered/map&lt;/code&gt; tag (reader kv defined &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clj-commons/ordered/blob/12044526cdda3f0ff08176666210022397621997/src/data_readers.clj#L2&quot;&gt;here&lt;/a&gt;, &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clj-commons/ordered/blob/12044526cdda3f0ff08176666210022397621997/src/flatland/ordered/map.clj#L149&quot;&gt;data reader fn&lt;/a&gt;). If I eval the following code, I get an exception thrown.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(do #ordered/map ([:b 2] [:a 1] [:d 4]))
Syntax error compiling fn* at (/src/example.clj:6:3).
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7119)
java.lang.IllegalArgumentException: Unable to resolve classname: IPersistentMap
	at clojure.lang.Compiler$HostExpr.tagToClass(Compiler.java:1129)
	at clojure.lang.Compiler.tagClass(Compiler.java:8693)
	at clojure.lang.Compiler$ObjExpr.emitValue(Compiler.java:4810)
	at clojure.lang.Compiler$ObjExpr.emitConstants(Compiler.java:4938)
	at clojure.lang.Compiler$ObjExpr.compile(Compiler.java:4616)
	at clojure.lang.Compiler$FnExpr.parse(Compiler.java:4110)
	at clojure.lang.Compiler.analyzeSeq(Compiler.java:7109)
	at clojure.lang.Compiler.analyze(Compiler.java:6793)
	at clojure.lang.Compiler.eval(Compiler.java:7178)
	at clojure.lang.Compiler.eval(Compiler.java:7171)
	at clojure.lang.Compiler.eval(Compiler.java:7136)
	at clojure.core$eval.invokeStatic(core.clj:3202)
	at clojure.core$eval.invoke(core.clj:3198)
	at nrepl.middleware.interruptible_eval$evaluate$fn__939.invoke(interruptible_eval.clj:91)
	at clojure.main$repl$read_eval_print__9110$fn__9113.invoke(main.clj:437)
	at clojure.main$repl$read_eval_print__9110.invoke(main.clj:437)
	at clojure.main$repl$fn__9119.invoke(main.clj:458)
	at clojure.main$repl.invokeStatic(main.clj:458)
	at clojure.main$repl.doInvoke(main.clj:368)
	at clojure.lang.RestFn.invoke(RestFn.java:1523)
	at nrepl.middleware.interruptible_eval$evaluate.invokeStatic(interruptible_eval.clj:84)
	at nrepl.middleware.interruptible_eval$evaluate.invoke(interruptible_eval.clj:56)
	at nrepl.middleware.interruptible_eval$interruptible_eval$fn__965$fn__969.invoke(interruptible_eval.clj:155)
	at clojure.lang.AFn.run(AFn.java:22)
	at nrepl.middleware.session$session_exec$main_loop__1067$fn__1071.invoke(session.clj:190)
	at nrepl.middleware.session$session_exec$main_loop__1067.invoke(session.clj:189)
	at clojure.lang.AFn.run(AFn.java:22)
	at java.base/java.lang.Thread.run(Thread.java:829)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The map is read and the data reader fn is called as expected.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def omap #ordered/map ([:b 2] [:a 1] [:d 4]))
=&amp;gt; #'example/omap
(type omap)
=&amp;gt; flatland.ordered.map.OrderedMap
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It's only when eval'ing just the tagged literal that the ex is thrown. Any idea why this is happening?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10945/why-do-some-reader-tags-throw-when-evaluated-on-their-own</guid>
<pubDate>Tue, 17 Aug 2021 17:52:04 +0000</pubDate>
</item>
<item>
<title>Why does *data-readers* require Vars?</title>
<link>https://ask.clojure.org/index.php/10934/why-does-data-readers-require-vars</link>
<description>&lt;p&gt;&lt;code&gt;edn/read&lt;/code&gt;'s &lt;code&gt;:readers&lt;/code&gt; arg &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojuredocs.org/clojure.edn/read&quot;&gt;accepts&lt;/a&gt; a map of tag symbols to data-reader functions, but &lt;code&gt;*data-readers*&lt;/code&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojuredocs.org/clojure.core/*data-readers*&quot;&gt;requires&lt;/a&gt; a map of tag symbols to data-reader Vars (global bindings). I'm just wondering if there is any reason for the discrepancy, because it is a bummer not to be able to use anonymous functions in &lt;code&gt;*data-readers*&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The context is I've made a handful of related reader tags (for tagged literals) that all work similarly, so rather than create 5 near identical reader functions I made 1, with two arity (tag, value), then I made a &lt;code&gt;reader-for&lt;/code&gt; function that returns a one-arity function as needed (using &lt;code&gt;partial&lt;/code&gt; and the two-arity function). This works just fine for &lt;code&gt;edn/read&lt;/code&gt; but when I went to use it in &lt;code&gt;*data-readers*&lt;/code&gt; it's a no-go because there is no Var for what comes out of &lt;code&gt;reader-for&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt; There are several workarounds. For example bind &lt;code&gt;*default-data-reader-fn*&lt;/code&gt;and make a function to dispatch to all my readers. Which is not particularly difficult but now I'm left with two artifacts instead of one - the map of readers for &lt;code&gt;edn/read&lt;/code&gt; and the function for &lt;code&gt;*default-data-reader-fn*&lt;/code&gt;. The map can be leveraged in the function of course. Or as an alternative I can just write the five functions -- or &quot;write&quot; them in a &lt;code&gt;doseq&lt;/code&gt;. But the little inconsistencies across how these tags are done is a little baffling. (For example, in addition to the &lt;code&gt;{tag-sym fn}&lt;/code&gt; map of &lt;code&gt;:reader&lt;/code&gt; and the &lt;code&gt;{tag-sym Var}&lt;/code&gt; map of &lt;code&gt;*data-readers*&lt;/code&gt;, there is also the &lt;code&gt;{unquoted-tag-sym-in-a-map-literal fn-sym}&lt;/code&gt; syntax of &lt;code&gt;data_readers.clj&lt;/code&gt;, which despite being a clj file does not seem to afford me the opportunity to do anything dynamic to define readers, just the literal map).&lt;/p&gt;
&lt;p&gt;I probably just don't grasp the practicalities/history/logic behind all this, if anyone can shed some light thanks in advance, if not that's fine too.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10934/why-does-data-readers-require-vars</guid>
<pubDate>Tue, 10 Aug 2021 19:04:31 +0000</pubDate>
</item>
<item>
<title>Clojure's handling of non-arabic numeral digits is surprising</title>
<link>https://ask.clojure.org/index.php/10767/clojures-handling-of-non-arabic-numeral-digits-surprising</link>
<description>&lt;p&gt;A friend of mine is writing a DSL and wants to use the character ૪ as part of his notation. If you try to use this character as part of a symbol in clojure you get an error like the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (read-string &quot;૪&quot;)
Execution error (NumberFormatException) at user/eval5 (REPL:1).
Invalid number: ૪
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The cause of this appears to be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (Character/isDigit \૪)
true
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The character is a digit in Gujarati script so java's Character/isDigit returns true, so the clojure reader tries to parse it as a number, but it can only handle arabic numerals (and maybe hex). &lt;/p&gt;
&lt;p&gt;It seems like if the reader is going to rely on Character/isDigit, it should be able to turn any of those characters into a number or the reader should allow &quot;digits&quot; it doesn't know how to handle to be symbols.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10767/clojures-handling-of-non-arabic-numeral-digits-surprising</guid>
<pubDate>Mon, 12 Jul 2021 18:52:13 +0000</pubDate>
</item>
<item>
<title>How to define constantly using #()?</title>
<link>https://ask.clojure.org/index.php/10487/how-to-define-constantly-using</link>
<description>&lt;p&gt;I started learning Clojure. The tutorial asks to define &lt;code&gt;constantly&lt;/code&gt;. I managed it using &lt;code&gt;fn&lt;/code&gt;. How to do it using &lt;code&gt;#()&lt;/code&gt;?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10487/how-to-define-constantly-using</guid>
<pubDate>Sun, 18 Apr 2021 07:18:37 +0000</pubDate>
</item>
<item>
<title>Are reader tags supposed to support non-ASCII characters?</title>
<link>https://ask.clojure.org/index.php/10481/are-reader-tags-supposed-to-support-non-ascii-characters</link>
<description>&lt;p&gt;I tried defining a Unicode data-literal tag, and was surprised to find that it throws an error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn wrap-λ [expr]
  `(fn [~'%] ~expr))
    
(set! *data-readers*
  (assoc *data-readers*
    'λ #'wrap-λ))

(read-string &quot;#λ(inc %)&quot;)
;; =&amp;gt; Execution error (ArrayIndexOutOfBoundsException) at lib/eval74486 (REPL:15).
;;    Index 955 out of bounds for length 256
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;955 is the Unicode codepoint for \λ, and the error suggests it only supports the ASCII range.&lt;br&gt;
The first few lines of the stacktrace:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;       LispReader.java:  840  clojure.lang.LispReader$DispatchReader/invoke
       LispReader.java:  285  clojure.lang.LispReader/read
       LispReader.java:  216  clojure.lang.LispReader/read
       LispReader.java:  205  clojure.lang.LispReader/read
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this expected behavior? Clojurescript does not have the same issue:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(cljs.reader/register-tag-parser! 'λ wrap-λ)
(cljs.reader/read-string &quot;#λ(inc %)&quot;)
;; =&amp;gt; (cljs.core/fn [% &amp;amp; args] (inc %))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10481/are-reader-tags-supposed-to-support-non-ascii-characters</guid>
<pubDate>Thu, 15 Apr 2021 05:48:03 +0000</pubDate>
</item>
<item>
<title>How to access string character values in a map</title>
<link>https://ask.clojure.org/index.php/10476/how-to-access-string-character-values-in-a-map</link>
<description>&lt;p&gt;I am working my way through a roman numerals clojure exercise.&lt;br&gt;
I have&lt;br&gt;
&lt;code&gt;(def roman-numerals {&quot;M&quot; 1000 &quot;D&quot; 500 &quot;C&quot; 100 &quot;L&quot; 50 &quot;X&quot; 10 &quot;V&quot; 5 &quot;I&quot; 1})&lt;/code&gt;&lt;br&gt;
and I'd like to convert let's say &quot;XVI&quot; to numbers - as a start. But&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(map #(println %)  (sequence &quot;XIV&quot;)) &lt;/code&gt;&lt;br&gt;
prints&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;X&lt;br&gt;
(nilI&lt;br&gt;
 nilV&lt;br&gt;
 nil)&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;and &lt;/p&gt;
&lt;p&gt;&lt;code&gt;(map #(get roman-numerals %)  (sequence &quot;XIV&quot;)) &lt;/code&gt;&lt;br&gt;
produces &lt;br&gt;
&lt;code&gt;(nil nil nil)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;How can I get map to use the actual characters out of the sequence?&lt;/p&gt;
&lt;p&gt;&lt;code&gt; (sequence &quot;XIV&quot;) =&amp;gt; (\X \I \V)&lt;/code&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10476/how-to-access-string-character-values-in-a-map</guid>
<pubDate>Wed, 14 Apr 2021 17:35:03 +0000</pubDate>
</item>
<item>
<title>http-kit authorization with api-key</title>
<link>https://ask.clojure.org/index.php/10411/http-kit-authorization-with-api-key</link>
<description>&lt;p&gt;I need to make an API call with  &lt;code&gt;http-kit&lt;/code&gt;  in Clojure where it uses &lt;code&gt;API-Key&lt;/code&gt; as authorization. That is, in Postman, you would usually have the option to add an &lt;code&gt;api-key&lt;/code&gt;, &lt;code&gt;api-value&lt;/code&gt; and the option to add it to &lt;code&gt;header&lt;/code&gt; or &lt;code&gt;query-params&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I know the following would be the way to go in case of basic-auth:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:url &quot;&amp;lt;api-url&amp;gt;&quot;
 :method :post
 :headers {&quot;Content-Type&quot; &quot;application/json&quot;}
 :basic-auth [&amp;lt;username&amp;gt; &amp;lt;password&amp;gt;]
 :body &amp;lt;body&amp;gt;)}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I need to make an API call with http-kit in Clojure where it uses API-Key as authorization. That is, in Postman, you would usually have the option to add an api-key, api-value and the option to add it to header or query-params.&lt;/p&gt;
&lt;p&gt;I know the following would be the way to go in case of basic-auth:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{:url &quot;&amp;lt;api-url&amp;gt;&quot;
 :method :post
 :headers {&quot;Content-Type&quot; &quot;application/json&quot;}
 :basic-auth [&amp;lt;username&amp;gt; &amp;lt;password&amp;gt;]
 :body &amp;lt;body&amp;gt;)}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;But a similar variation isn't working with api-key version. So far, I have tried:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:basic-auth [&amp;lt;api-key&amp;gt; &amp;lt;api-value&amp;gt;]}

{:query-params {&amp;lt;api-key&amp;gt; &amp;lt;api-value&amp;gt;}}

{:query-params {:key &amp;lt;api-key&amp;gt;, :value &amp;lt;api-value&amp;gt;}}

{:headers {&quot;Content-Type&quot; &quot;application/json&quot;, 
                    &amp;lt;api-key&amp;gt; &amp;lt;api-value&amp;gt;}

{:api-key [&amp;lt;api-key&amp;gt; &amp;lt;api-value&amp;gt;]}

{:api-key {&amp;lt;api-key&amp;gt; &amp;lt;api-value&amp;gt;}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and other variations, but it doesn't seem to be working.&lt;/p&gt;
&lt;p&gt;Note: &lt;br&gt;
- The authorization works on postman but I couldn't test the full api call there because the body is too long and too complex to copy, and the authorization isn't working from the application.&lt;br&gt;
- I keep getting a 401 error with all these different combinations, and some give typeerrors depending on where in the request they're placed. &lt;br&gt;
- The documentation isn't really useful. &lt;a rel=&quot;nofollow&quot; href=&quot;https://documenter.getpostman.com/view/9780542/TVmHDetH#e4296d1e-58f4-4f6d-873f-04fd8a69c872&quot;&gt;Here&lt;/a&gt; is the link. &lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10411/http-kit-authorization-with-api-key</guid>
<pubDate>Wed, 07 Apr 2021 11:07:39 +0000</pubDate>
</item>
<item>
<title>How to draw expression tree for function definition</title>
<link>https://ask.clojure.org/index.php/10328/how-to-draw-expression-tree-for-function-definition</link>
<description>&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/WNo9ynv.png&quot; alt=&quot;https://imgur.com/a/X11sBxI&quot;&gt;&lt;/p&gt;
&lt;p&gt;Hi. As I'm learning clojure, I decided to draw a expression tree for my factorial code.&lt;/p&gt;
&lt;p&gt;However, It seems like using &lt;strong&gt;(2)&lt;/strong&gt; defn or &lt;strong&gt;(1)&lt;/strong&gt; def and fn doesn't generate a nice looking expression tree.&lt;/p&gt;
&lt;p&gt;So I've come up with &lt;strong&gt;(3)&lt;/strong&gt; mydef which reveals the structure of a function and its argument. Drawn in the form of expression tree, this makes sense.&lt;/p&gt;
&lt;p&gt;My question is: &lt;br&gt;
1) Does &lt;strong&gt;(1)&lt;/strong&gt; and &lt;strong&gt;(2)&lt;/strong&gt; actually makes more sense?&lt;br&gt;
2) is there a reason that function definition is not written like &lt;strong&gt;(3)&lt;/strong&gt; mydef?&lt;/p&gt;
&lt;p&gt;Here is the link to the diagram if anyone wants to use it:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://drive.google.com/file/d/1hUnifN8GM5wGr9r8lE1jgCPqU4zH8iYE/view?usp=sharing&quot;&gt;https://drive.google.com/file/d/1hUnifN8GM5wGr9r8lE1jgCPqU4zH8iYE/view?usp=sharing&lt;/a&gt; &lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10328/how-to-draw-expression-tree-for-function-definition</guid>
<pubDate>Thu, 11 Mar 2021 20:25:29 +0000</pubDate>
</item>
<item>
<title>Problem using numbers as keywords</title>
<link>https://ask.clojure.org/index.php/10225/problem-using-numbers-as-keywords</link>
<description>&lt;p&gt;In Clojure 1.10.1 using numbers in qualified keywords results in a Syntax error&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; :ns/1
Syntax error reading source at (REPL:136:1).
Invalid token: :ns/1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I can however construct it using &lt;code&gt;keyword&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;users&amp;gt; (keyword &quot;ns&quot; &quot;1&quot;)
:ns/1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My problem is that the second form is not a legal &lt;em&gt;test expression&lt;/em&gt; to use in a &lt;code&gt;case&lt;/code&gt; statement.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10225/problem-using-numbers-as-keywords</guid>
<pubDate>Sun, 21 Feb 2021 13:42:41 +0000</pubDate>
</item>
<item>
<title>Function calls to generate docstrings?</title>
<link>https://ask.clojure.org/index.php/10161/function-calls-to-generate-docstrings</link>
<description>&lt;p&gt;I was curious if a function could be defined like the following:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn my-cli-func
  (docstr 
    :description &quot;Some CLI function with complex args to do something cool&quot;
    [[&quot;-p&quot; &quot;--port&quot; :port &quot;Port to listen for connections on&quot;]])
  [args]
  &quot;...&quot;)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The intention is that docstr could generate a docstring in a consistent format I can validate and such. That did not work as I get an error about where the Parameter declaration should be.&lt;/p&gt;
&lt;p&gt;I'm guessing it could be done with a &lt;code&gt;defn&lt;/code&gt; wrapper macro but probably not worth the hassle right now.&lt;/p&gt;
&lt;p&gt;I was curious if there was a design decision to not allow meta programming there or if it's some kind of mechanical restriction due to the implementation. &lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10161/function-calls-to-generate-docstrings</guid>
<pubDate>Wed, 10 Feb 2021 05:36:58 +0000</pubDate>
</item>
<item>
<title>can i bind in a for comprehension with a map?</title>
<link>https://ask.clojure.org/index.php/10104/can-i-bind-in-a-for-comprehension-with-a-map</link>
<description>&lt;pre&gt;&lt;code&gt;(defn get-pins [observed]
  (let [num (count observed)
        keypad {\1 [1 2 4] \2 [2 1 5 3] \3 [3 2 6]
                \4 [4 1 5 7] \5 [5 2 6 8 4] \6 [6 3 5 9]
                \7 [7 4 8] \8 [8 5 9 0 7] \9 [9 6 8] \0 [0 8]}
        observed-map (zipmap [:a :b :c :d] (map keypad observed))]
    (case num
      1 (for [a (:a observed-map)]
          (str a))
      2 (for [a (:a observed-map)
              b (:b observed-map)]
         (str a b))
      3 (for [a (:a observed-map)
              b (:b observed-map)
              c (:c observed-map)]
         (str a b c))
      4 (for [a (:a observed-map)
              b (:b observed-map)
              c (:c observed-map)
              d (:d observed-map)]
         (str a b c d))
       &quot;default&quot;)))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10104/can-i-bind-in-a-for-comprehension-with-a-map</guid>
<pubDate>Tue, 26 Jan 2021 19:09:50 +0000</pubDate>
</item>
</channel>
</rss>