<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in Syntax and reader</title>
<link>https://ask.clojure.org/index.php/questions/clojure/reader</link>
<description></description>
<item>
<title>destructuring with :keys! and :or</title>
<link>https://ask.clojure.org/index.php/15179/destructuring-with-keys-and-or</link>
<description>&lt;p&gt;I'm trying Clojure 1.13.0-alpha4.  I have a problem with :keys! and :or.  The first example works as expected with the old :keys.  The second example gives me a syntax error when I switch to the new :keys!.  The third example works when I avoid the required key in the defaults. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt; (let [{:keys [a] :or {:a 1}} {:a 2}] a)
 ;=&amp;gt; 2
    
(let [{:keys! [a] :or {:a 1}} {:a 2}] a)
Syntax error macroexpanding let at (REPL:1:1).
Can't supply default value for required key: :a

(let [{:keys! [a] :or {:b 1}} {:a 2}] a)
;=&amp;gt; 2
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15179/destructuring-with-keys-and-or</guid>
<pubDate>Tue, 14 Jul 2026 19:52:33 +0000</pubDate>
</item>
<item>
<title>Additional handling for `&amp;` symbol in map destructuring for :keys/:syms/:strs could be a breaking change.</title>
<link>https://ask.clojure.org/index.php/15171/additional-handling-symbol-destructuring-breaking-change</link>
<description>&lt;p&gt;Before 1.13.0-alpha1:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [{:keys [&amp;amp;]} {:&amp;amp; 1}] &amp;amp;)
;; =&amp;gt; 1

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;After:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [{:keys [&amp;amp;]} {:&amp;amp; 1}] &amp;amp;)
Syntax error compiling at (REPL:1:1).
Unable to resolve symbol: &amp;amp; in this context
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15171/additional-handling-symbol-destructuring-breaking-change</guid>
<pubDate>Thu, 09 Jul 2026 10:01:25 +0000</pubDate>
</item>
<item>
<title>Syntax-quoted lists can return nil, differs from ClojureScript</title>
<link>https://ask.clojure.org/index.php/15152/syntax-quoted-lists-can-return-differs-from-clojurescript</link>
<description>&lt;p&gt;Syntax quoted lists can return &lt;code&gt;nil&lt;/code&gt; if only empty seqables are spliced into it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.5
user=&amp;gt; `(~@[])
nil
user=&amp;gt; `(~@[] ~@[])
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, the implementation then ensures syntax-quoted empty lists are not nil:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.5
user=&amp;gt; `()
()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;ClojureScript returns an empty list in these cases:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;`(~@[])
=&amp;gt; ()
`(~@[] ~@[])
=&amp;gt; ()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The expansion of syntax quote itself is not necessarily a problem if it differs between platforms, but here the evaluation of the expansion differs. This can cause macros to behave differently between platforms (e.g., JVM Clojure vs bootstrapped cljs).&lt;/p&gt;
&lt;p&gt;This behavior seems to be present with all versions of Clojure &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/f85444e6f890eb585e598efefdbd84727427e0a4/src/jvm/clojure/lang/LispReader.java#L731&quot;&gt;including 1.0.0&lt;/a&gt;, so perhaps the ship has sailed here. I went searching for an existing issue or documentation and AFAICT only &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-1425&quot;&gt;CLJ-1425&lt;/a&gt; mentions this oddity.&lt;/p&gt;
&lt;p&gt;The reference docs for &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/reader#syntax-quote&quot;&gt;Syntax Quote&lt;/a&gt; also seem to contradict this behavior:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;For Lists/Vectors/Sets/Maps, syntax-quote establishes a template of the corresponding data structure.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15152/syntax-quoted-lists-can-return-differs-from-clojurescript</guid>
<pubDate>Sun, 28 Jun 2026 20:43:55 +0000</pubDate>
</item>
<item>
<title>`eval` using functions with metadata</title>
<link>https://ask.clojure.org/index.php/15115/eval-using-functions-with-metadata</link>
<description>&lt;p&gt;TIL:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(eval (list + 1 2)) ; works
(eval (list (var-get #'+) 1 2)) ; works
(eval (list (fn [a b] (+ a b)) 1 2)) ; works

(defmacro m [] `(~(fn [a b] (+ a b)) 1 2))
(m) ; also works

;; however, if the function has any metadata:
(eval (list (with-meta + {}) 1 2))
;; ^ fails, No matching ctor found for class clojure.lang.AFunction$1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This was unintuitive to discover.&lt;/p&gt;
&lt;p&gt;I solved it locally with a little helper:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn val-&amp;gt;expr [v]
  (if (symbol? v)
    `'~v
    (cond-&amp;gt; v
      (and (fn? v) (not (nil? (meta v))))
      (-&amp;gt; (with-meta nil)
          (list (-&amp;gt; v meta (update-vals val-&amp;gt;expr)))
          (conj `with-meta)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But this takes special handling. I wonder if something similar would not be possible on a &quot;matching ctor&quot;-level, possibly also for &lt;code&gt;comp&lt;/code&gt;, &lt;code&gt;every-pred?&lt;/code&gt;, etc. It would be fairly trivial even in userland to have versions of these functions which carry metadata sufficient to recreate expressions, e.g. &lt;code&gt;comp&lt;/code&gt; storing the list of functions, and then &lt;code&gt;eval&lt;/code&gt;, on encountering &lt;code&gt;No matching ctor found for class clojure.core$comp$fn__5921&lt;/code&gt;, can instead pull out the list of functions from that value and evaluate &lt;code&gt;(list* comp (:composed-fns (meta v)))&lt;/code&gt; (or some such) instead.&lt;/p&gt;
&lt;p&gt;I think this would be great to have in the core lib, at least for metadata and core libs functions like &lt;code&gt;comp&lt;/code&gt;, &lt;code&gt;some-fn&lt;/code&gt;, &lt;code&gt;every-pred?&lt;/code&gt;, and &lt;code&gt;complement&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Note, I'm not talking about adding or changing ctors for these necessarily. A hook for taking unconstructable values and making a constructable value out of them would serve just as well, maybe even a multifn.&lt;/p&gt;
&lt;p&gt;Strictly in userland and without core lib support, I suppose the cleanest way to do something like this is a custom protocol and probably monkeypatch some core libs functions (maybe &lt;code&gt;eval&lt;/code&gt;?)&lt;/p&gt;
&lt;p&gt;So I suppose my questions are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Is this something you agree would be good to have in general? Or is this by design for some reason I can't see?&lt;/li&gt;
&lt;li&gt;Would this be good and practical to have in the corelib? Oughtn't be a breaking change at least&lt;/li&gt;
&lt;li&gt;If no, is there currently any sane way to apply my solution in a more systemic way than wrapping every relevant value with a &lt;code&gt;val-&amp;gt;expr&lt;/code&gt; call?&lt;/li&gt;
&lt;/ol&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15115/eval-using-functions-with-metadata</guid>
<pubDate>Mon, 01 Jun 2026 14:33:00 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt;&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://www.oracle.com/technical-resources/articles/javase/supplementary.html&quot;&gt;For historical reasons&lt;/a&gt; the JVM type system's support for Unicode code points is poor, and while this is usually invisible to the developer it becomes a hassle when String literals containing non-Latin1 code points are used in code.  It also becomes particularly problematic when cross-platform (cljc) code is attempting to do this, since other platforms may not share this historical oddity so solutions that &quot;work&quot; in ClojureJVM may break in other dialects.&lt;/p&gt;
&lt;p&gt;For example, the &lt;a rel=&quot;nofollow&quot; href=&quot;https://emojipedia.org/transgender-flag#technical&quot;&gt;transgender flag emoji&lt;/a&gt; (a single grapheme cluster that happens to be defined by 5 Unicode code points) cannot easily be constructed at the REPL or in a source file without detailed knowledge of the JVM's history (and associated knowledge of UTF-16, an increasingly obsolete character encoding).&lt;/p&gt;
&lt;p&gt;Using the documented code points for this grapheme cluster with the JVM's Unicode escaping mechanism does &lt;em&gt;not&lt;/em&gt; give the expected outcome:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.ibb.co/gM2XsWBG/Screenshot-2026-01-12-at-11-13-38-AM.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;The correct, but unintuitive solution is to remember that the JVM does not directly support Unicode code points in the supplemental planes, and then to translate the supplemental code point &lt;code&gt;U+1F3F3&lt;/code&gt; into its UTF-16 code unit / surrogate pair representation:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.ibb.co/60b1ZLXh/Screenshot-2026-01-12-at-11-15-56-AM.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;Note: I had to use screenshots for this, since ask.clojure doesn't appear to support Unicode supplemental code points properly either...&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Question/request/proposal&lt;/strong&gt;&lt;br&gt;
Clojure can sidestep this issue in a purely accretive manner, providing better consistency across the JVM and other runtimes, by adding direct support for Unicode literals.&lt;/p&gt;
&lt;p&gt;This would involve adding a new literal syntax that represents a single Unicode code point, and perhaps also a new literal syntax that represents a sequence of Unicode code points (perhaps supporting not only the novel Unicode code point literal, but also the existing Character and String literals).  Both of these new literals would produce a standard JVM (or JavaScript, or ...) String object, in whatever native encoding those objects employ on their respective platforms - after such literals are read, it's all just the extant String data type - there is no runtime impact.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;An &lt;em&gt;example&lt;/em&gt; literal syntax&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;While I am not proposing a specific syntax for these new literals here (though such a task is a necessary step), for illustrative purposes here is an example of what these literals &lt;em&gt;might&lt;/em&gt; approximately look like:&lt;/p&gt;
&lt;p&gt;Single Unicode code point literals:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;#U+0061&lt;/code&gt;: produces a String containing the Latin letter a: &lt;code&gt;&quot;a&quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;#U+1F921&lt;/code&gt;: produces a String containing &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.compart.com/en/unicode/U+1F921&quot;&gt;the clown emoji&lt;/a&gt; (which ask.clojure cannot display)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Sequences of Unicode code point literals:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;#U+[U+0061 U+0020 U+1F921]&lt;/code&gt;: produces the 3 grapheme cluster String: &lt;code&gt;&quot;a &amp;lt;clown emoji&amp;gt;&quot;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;#U+[&quot;a &quot; U+1F921]&lt;/code&gt;: produces the same String, but demonstrates why it may be useful to support a mix of literals within the sequence (for readability)&lt;/li&gt;
&lt;li&gt;&lt;code&gt;#U+[\a \space U+1F921]&lt;/code&gt;: ditto&lt;/li&gt;
&lt;li&gt;&lt;code&gt;#U+[U+1F3F3 U+FE0F U+200D U+26A7 U+FE0F]&lt;/code&gt;: produces a String containing a single grapheme cluster (the transgender flag emoji)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This final example is an ideal test case, since the transgender flag emoji is a single Unicode grapheme cluster, defined by 5 Unicode code points, but on the JVM (for the historical reason listed originally) is made up of &lt;em&gt;6&lt;/em&gt; Characters.&lt;/p&gt;
&lt;p&gt;Note that the sequence literal may not be necessary, since &lt;code&gt;str&lt;/code&gt; could be used with the single code point literal syntax; e.g. &lt;code&gt;(str #U+1F3F3 #U+FE0F #U+200D #U+26A7 #U+FE0F)&lt;/code&gt;.  Whether shifting the cost of string concatenation from read-time to runtime matters or not is another topic worthy of deeper consideration.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Other notes&lt;/strong&gt;&lt;br&gt;
Orthogonal to this proposal (at least from a Clojure core perspective; from a user perspective they're closely related), it would also be useful if Clojure core (perhaps in the &lt;code&gt;clojure.string&lt;/code&gt; namespace) had functions to turn Strings into sequences of code points (as integers) and vice versa.  Both the JVM and JavaScript provide native APIs for doing this (and presumably other platforms do too), but providing these as standard functions in Clojure core (similar to what was done with &lt;code&gt;parse-long&lt;/code&gt;, &lt;code&gt;parse-double&lt;/code&gt;, and &lt;code&gt;parse-boolean&lt;/code&gt; in Clojure v1.11) has value and is also purely accretive.&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</guid>
<pubDate>Mon, 12 Jan 2026 20:02:41 +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>Aliased namespace in tagged literal</title>
<link>https://ask.clojure.org/index.php/14829/aliased-namespace-in-tagged-literal</link>
<description>&lt;p&gt;&lt;strong&gt;Set up&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Tagged literals are defined by setting a namespaced symbol in &lt;code&gt;data_readers.clj&lt;/code&gt; (or &lt;code&gt;data_readers.cljc&lt;/code&gt;). At load, Clojure merges all of the maps defined in &lt;code&gt;data_readers.clj(c)&lt;/code&gt; files found on the classpath into a single map. At read time, the symbol following a &lt;code&gt;#&lt;/code&gt; is checked in the merged data readers map, which determines which var to call with the contents of the following form.&lt;/p&gt;
&lt;p&gt;For example, &lt;code&gt;#foo/bar [1 2 3]&lt;/code&gt; leads to the reader calling the equivalent of &lt;code&gt;(get *data-readers* 'foo/bar)&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Problem statement&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The tag of a tagged literal must be determined when it is created. The namespace of the chosen tag is set and cannot be changed by a user. Unlike a fully qualified symbol with an aliased namespace, a tagged literal must what was chosen by the author.&lt;/p&gt;
&lt;p&gt;As an author of tagged literals, I want to write tags that will not clash with other tags by giving them complex/deep namespaces. For example, &lt;code&gt;{noahtheduke.lazytest/expect noahtheduke.lazytest/expect}&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;As a user of tagged literals, I want to alias the namespace of tags and use it in my code. For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; in src/data_readers.clj
{noahtheduke.lazytest/expect noahtheduke.lazytest/expect}

;; in test/noahtheduke/example_project/main-test.clj
(ns noahtheduke.example-project.main-test
  (:require
   [noahtheduke.lazytest :as-alias lt]
   [noahtheduke.lazytest.core :refer [defdescribe it]]))

(defdescribe some-test
  (it &quot;works&quot;
    #lt/expect (= 1 2)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;EDN&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;This is not related to edn at all and any potential change will be to Clojure itself.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14829/aliased-namespace-in-tagged-literal</guid>
<pubDate>Thu, 11 Dec 2025 20:01:16 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;Following links and snippets are about clojure.edn but because this logic is the same in clojure it also affects clojure reader as well.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/EdnReader.java#L28&quot;&gt;Here&lt;/a&gt; is how symbol pattern is defined:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[:]?([\D&amp;amp;&amp;amp;[^/]].*/)?(/|[\D&amp;amp;&amp;amp;[^/]][^/]*)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is eagerly matching prefix until &lt;strong&gt;the last&lt;/strong&gt; slash character, after that it matches symbol name.&lt;/p&gt;
&lt;p&gt;Then &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/EdnReader.java#L289-L311&quot;&gt;there&lt;/a&gt; is a wrong analysis of matched groups happen: ns is incorrectly set to everything until the last slash with &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/EdnReader.java#L296&quot;&gt;validation&lt;/a&gt; that it is not ends with :/&lt;/p&gt;
&lt;p&gt;Then in Symbol.intern call there is an another lookup for &lt;strong&gt;the first&lt;/strong&gt; slash to split symbol into namespace and name.&lt;/p&gt;
&lt;p&gt;The result is that keywords like this: &quot;:/-/-&quot;, end up with namespace set to empty string &quot;&quot;.&lt;/p&gt;
&lt;p&gt;Looks like the least intrusive way to fix it is to use the same logic to find namespace borders in both places:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;during symbol reading, lookup the first / to set ns instead of using the first matching group&lt;/li&gt;
&lt;li&gt;in symbol interning the logic is correct&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Another option is to use different regular expression: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[:]?([\D&amp;amp;&amp;amp;[^/]][^/]*/)?(/|[\D&amp;amp;&amp;amp;[^/]].*[^/])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This matches symbol prefix til &lt;strong&gt;the first&lt;/strong&gt; slash keeping restriction &quot;name can't end with slash&quot;.&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</guid>
<pubDate>Fri, 05 Dec 2025 09:56:54 +0000</pubDate>
</item>
<item>
<title>[clojure.edn] Leading zeros in numbers</title>
<link>https://ask.clojure.org/index.php/14798/clojure-edn-leading-zeros-in-numbers</link>
<description>&lt;p&gt;clojure.edn allow leading zeros ending up reading such number as octal representation. The problem is that it is also allowed to have indefinite amount of leading zeros for octals:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;000000000000042  ;; =&amp;gt; 34
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and when there is a suffix &quot;M&quot; that forces floating point representation the same string become float 42 stripping all leading zeros.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;000000000000042M ;; =&amp;gt; 42M
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At the same time EDN specification forbids integers with leading zeros at all even for floats.&lt;br&gt;
I found a ticket about leading zeros in data.json but I think it should be expanded to cover clojure as well.&lt;/p&gt;
&lt;p&gt;In the same scope but origin is in the EDN spec:&lt;br&gt;
float specification allows leading zeroes in exponent and only zeros in fractional parts:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;0.00000000...00
0.0e0001
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;probably because of that clojure.edn read such numbers without error too. &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</guid>
<pubDate>Thu, 04 Dec 2025 13:31:23 +0000</pubDate>
</item>
<item>
<title>Support characters beyond basic multilingual plane</title>
<link>https://ask.clojure.org/index.php/14790/support-characters-beyond-basic-multilingual-plane</link>
<description>&lt;p&gt;For now characters are defined as &lt;code&gt;\uXXXX&lt;/code&gt; so it is not possible to encode character beyond BMP. Surrogate pairs is a common way to encode such characters but LispReader explicitly throws when it sees it - &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L1217-L1218&quot;&gt;https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LispReader.java#L1217-L1218&lt;/a&gt;&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</guid>
<pubDate>Tue, 02 Dec 2025 15:10:36 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;Right now double colon is allowed only when used as a start of not empty identifier prefix. I wonder is there some explanation why it is forbidden anywhere else?&lt;/p&gt;
&lt;p&gt;I found original commit, where this was introduced. &lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/commit/005ea1b5f96c5bb762e155032a865e29ad71bcf3&quot;&gt;https://github.com/clojure/clojure/commit/005ea1b5f96c5bb762e155032a865e29ad71bcf3&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But commit message has no explanation why it allows only non-repeating colon&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</guid>
<pubDate>Thu, 27 Nov 2025 12:15:33 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;pre&gt;&lt;code&gt;user=&amp;gt; (clojure.edn/read-string &quot;777/2&quot;) ;; no surprises
777/2
user=&amp;gt; (clojure.edn/read-string &quot;0777/2&quot;) ;; wait, 0777 supposed to be 511
777/2
user=&amp;gt; (clojure.edn/read-string &quot;0x777/2&quot;) ;; hexadecimal suddenly throws
Execution error (NumberFormatException) at user/eval175 (REPL:1).
Invalid number: 0x777/2
user=&amp;gt; (clojure.edn/read-string &quot;32r777/2&quot;) ;; radix throws as well
Execution error (NumberFormatException) at user/eval177 (REPL:1).
Invalid number: 32r777/2
user=&amp;gt; (clojure.edn/read-string &quot;777N/2&quot;) ;; same for BigInt
Execution error (NumberFormatException) at user/eval181 (REPL:1).
Invalid number: 777N/2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Inconsistent part here is octal integer numerator form. I would expect it to fail the same way as the rest of this list but not to silently drop leading zero and turn to not octal form at all.&lt;/p&gt;
&lt;p&gt;Second part of the question is: Why other forms throws at all?&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</guid>
<pubDate>Sat, 22 Nov 2025 17:12:47 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;According to edn-format/edn specification &lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;A reader should not call user-supplied tag handlers during the processing of the element to be discarded.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;But with clojure.edn/read and its derivatives execute provided reader functions under discard tag:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (clojure.edn/read-string {:readers {'foo (fn [val] (prn &quot;!!!&quot;) val)}} &quot;#_ #foo [1 2 3]&quot;)
&quot;!!!&quot;
Execution error at user/eval216 (REPL:1).
EOF while reading
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same happen with clojure.core/read and its derivatives:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (binding [*data-readers* {'foo (fn [val] (prn &quot;!!!&quot;) val)}] (read-string &quot;#_ #foo [1 2 3]&quot;))
&quot;!!!&quot;
Execution error at user/eval146 (REPL:1).
EOF while reading
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I understand that Clojure' reader does not provide explicit description of what is executed during reading out form to be discarded except &quot;The form following #_ is completely skipped by the reader.&quot; but I think it is worth to mention that here.&lt;/p&gt;
&lt;p&gt;After realisation that this post is not qualifies as &quot;ask&quot;&lt;/p&gt;
&lt;p&gt;To summarize:&lt;br&gt;
Is this a bug in clojure edn specification implementation?&lt;br&gt;
Is the edn specification no longer accurate?&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</guid>
<pubDate>Thu, 20 Nov 2025 14:57:19 +0000</pubDate>
</item>
<item>
<title>.pow bigdec vs bigint</title>
<link>https://ask.clojure.org/index.php/14640/pow-bigdec-vs-bigint</link>
<description>&lt;p&gt;Consider this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (.pow (bigdec 2) 3)
8M

user&amp;gt; (.pow (bigint 2) 3)
Execution error (IllegalArgumentException) at foo/eval10898 (REPL:1093).
No matching method pow found taking 1 args for class clojure.lang.BigInt
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Is that an intentional choice in the language?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Note that this works:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (.pow (biginteger 2) 3)
8
user=&amp;gt; (type (.pow (biginteger 2) 3))
java.math.BigInteger
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Except the type is not &lt;code&gt;clojure.lang.BigInt&lt;/code&gt;, but &lt;code&gt;java.math.BigInteger&lt;/code&gt;, which are different types.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14640/pow-bigdec-vs-bigint</guid>
<pubDate>Sat, 26 Jul 2025 09:15:29 +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>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</link>
<description>&lt;p&gt;I've noticed that &lt;code&gt;clojure.edn&lt;/code&gt; parser will skip rest of the file if it manages to find the first valid token that will complete collection. For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; demo.edn
{
 :foo 1
 :bar 2 }
 :baz 3 
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(require '[clojure.edn :as edn]
         '[clojure.java.io :as io])

(with-open [r (io/reader &quot;demo.edn&quot;)]
  (edn/read (java.io.PushbackReader. r)))

user=&amp;gt; {:foo 1, :bar 2}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It will also ignore rest of the file when the file is clearly malformed:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{
 :foo 1
 :bar 2 }
xxxx yyyy }}}}} {{{{ ((
 :baz 3 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;it returns again:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; {:foo 1, :bar 2}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I was expecting it to throw EOF exception or at least '}' mismatch. Is this behavior by design or a possible bug?&lt;/p&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</guid>
<pubDate>Wed, 07 May 2025 12:29:34 +0000</pubDate>
</item>
<item>
<title>Symbols with leading slashes</title>
<link>https://ask.clojure.org/index.php/14506/symbols-with-leading-slashes</link>
<description>&lt;p&gt;The Clojure reference states that a slash may occur only once in the middle of a symbol ( &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/reader#_symbols&quot;&gt;https://clojure.org/reference/reader#_symbols&lt;/a&gt; ), yet, the core &lt;code&gt;symbol&lt;/code&gt; function permits symbols with leading slash non-conformingly ( &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojuredocs.org/clojure.core/symbol#example-542692d5c026201cdc3270a0&quot;&gt;https://clojuredocs.org/clojure.core/symbol#example-542692d5c026201cdc3270a0&lt;/a&gt; ), and there has been the following thread here: &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/1510/allow-leading-slashes-in-unqualified-symbol-names&quot;&gt;https://ask.clojure.org/index.php/1510/allow-leading-slashes-in-unqualified-symbol-names&lt;/a&gt; .&lt;br&gt;
Is there any more info available why only a single slash is allowed in the middle, and if either leading slashes may eventually be allowed or the &lt;code&gt;symbol&lt;/code&gt; function be made conforming?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14506/symbols-with-leading-slashes</guid>
<pubDate>Thu, 17 Apr 2025 07:09:27 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;It's a rather frequent question where somebody gets a syntax error when trying to use something like &lt;code&gt;{:keys [a b ...] :or {b a}}&lt;/code&gt;. The most recent instance: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1KBA2/p1742549907988549&quot;&gt;https://clojurians.slack.com/archives/C03S1KBA2/p1742549907988549&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The error is as user-unfriendly as it gets and the behavior is also counter-intuitive if you don't happen to know the insides of destructuring and maps.&lt;/p&gt;
&lt;p&gt;Perhaps it would make sense to alter the destructuring impl for when the default value in &lt;code&gt;:or&lt;/code&gt; is not a primitive. So instead of being expanded to &lt;code&gt;b (get map__1 :b a)&lt;/code&gt; it's expanded to &lt;code&gt;b (get map__1 :b ::not-found)&lt;/code&gt; with a subsequent rebinding to &lt;code&gt;b (if (identical? b ::not-found) a b)&lt;/code&gt; after all the other keys have already been extracted.&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</guid>
<pubDate>Fri, 21 Mar 2025 10:04:09 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;For comparisons (&lt;code&gt;= &amp;lt; &amp;lt;= &amp;gt; &amp;gt;= ==&lt;/code&gt;) arity 3 and higher are much slower than doing e.g. &lt;code&gt;(and (&amp;lt; a b) (&amp;lt; b c))&lt;/code&gt;. The arity 3 is in my research rather less common but still used in e.g. Manifold stream.clj [0] or rrb_vector rrbt.clj [1]. Arity 3 is idiomatic in places, where you compare lower and upper bound for a &quot;variable&quot;. However, I don't think arity 4 and higher is used much in practical code. At least I haven't found any interesting instances of such a use.&lt;/p&gt;
&lt;p&gt;An example implementation (based on the one currently in core) could be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn &amp;lt;'
  &quot;Returns non-nil if nums are in monotonically increasing order,
  otherwise false.&quot;
  {:inline         (fn [x y] `(. clojure.lang.Numbers (lt ~x ~y)))
   :inline-arities #{2}
   :added          &quot;1.0&quot;}
  ([x] true)
  ([x y] (. clojure.lang.Numbers (lt x y)))
  ([x y z] (and (&amp;lt;' x y) (&amp;lt;' y z)))
  ([x y z &amp;amp; more]
   (if (&amp;lt;' x y z)
     (if (next more)
       (recur y z (first more) (next more))
       (&amp;lt;' z (first more)))
     false)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;[0] &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clj-commons/manifold/blob/c3fc69066f3abba0b5ab0f4c2b1c4338bcc61d19/src/manifold/stream.clj#L978&quot;&gt;https://github.com/clj-commons/manifold/blob/c3fc69066f3abba0b5ab0f4c2b1c4338bcc61d19/src/manifold/stream.clj#L978&lt;/a&gt;&lt;br&gt;
[1] &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.rrb-vector/blob/master/src/main/clojure/clojure/core/rrb_vector/rrbt.clj&quot;&gt;https://github.com/clojure/core.rrb-vector/blob/master/src/main/clojure/clojure/core/rrb_vector/rrbt.clj&lt;/a&gt;&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</guid>
<pubDate>Tue, 16 Jan 2024 22:14:09 +0000</pubDate>
</item>
<item>
<title>Can Clojure support a byte-array literal?</title>
<link>https://ask.clojure.org/index.php/13534/can-clojure-support-a-byte-array-literal</link>
<description>&lt;p&gt;Byte arrays are fundamental to many domains: cryptography, audio and video processing, file handling, socket ops, etc.  Clojure's host platforms support byte arrays and Clojure itself even offers an immutable byte array (&lt;code&gt;clojure.core.Vec&lt;/code&gt;). &lt;/p&gt;
&lt;p&gt;Unfortunately, there is no support for a byte array literal and &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojureverse.org/t/clojure-byte-array-literal/6434&quot;&gt;various&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojureverse.org/t/tagged-literal-for-clojure-core-vec-not-possible-for-clojure/6452&quot;&gt;attempts&lt;/a&gt; to add support have not been successful for surprising reasons.&lt;/p&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;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13534/can-clojure-support-a-byte-array-literal</guid>
<pubDate>Sun, 10 Dec 2023 02:44:53 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;Reproducible test case:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns bug)
(require '[clojure.data.xml :as xml] #?@(:cljs [[clojure.data.xml.js.dom :as dom]]))
(def opts {:features #{:clj} :read-cond :allow})
(read-string opts &quot;#?(:cljs {:a ::dom/Element})&quot;)
; Execution error at bug/eval30984 (REPL:534).
; Invalid token: ::dom/Element
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Stack trace:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clojure.lang.Util/runtimeException (Util.java:221)
clojure.lang.LispReader/interpretToken (LispReader.java:412)
clojure.lang.LispReader/read (LispReader.java:305)
clojure.lang.LispReader/readDelimitedList (LispReader.java:1398)
clojure.lang.LispReader$MapReader/invoke (LispReader.java:1355)
clojure.lang.LispReader/read (LispReader.java:285)
clojure.lang.LispReader/access$900 (LispReader.java:41)
clojure.lang.LispReader$ConditionalReader/readCondDelimited (LispReader.java:1584)
clojure.lang.LispReader$ConditionalReader/invoke (LispReader.java:1659)
clojure.lang.LispReader$DispatchReader/invoke (LispReader.java:853)
clojure.lang.LispReader/read (LispReader.java:285)
clojure.lang.RT/readString (RT.java:1876)
clojure.core/read-string (core.clj:3817)
clojure.core/read-string (core.clj:3806)
bug/eval30984 (NO_SOURCE_FILE:534)
clojure.lang.Compiler/eval (Compiler.java:7194)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Real-world scenario:&lt;/p&gt;
&lt;p&gt;Reading &lt;code&gt;data.xml-0.2.0-alpha8/clojure/data/xml/spec.cljc&lt;/code&gt; errors in line 45: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/data.xml/blob/v0.2.0-alpha8/src/main/resources/clojure/data/xml/spec.cljc#L45&quot;&gt;https://github.com/clojure/data.xml/blob/v0.2.0-alpha8/src/main/resources/clojure/data/xml/spec.cljc#L45&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Note that stack trace is different there:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;; Caused by: clojure.lang.ExceptionInfo: [line 45, col 28] Invalid keyword: ::dom/Element. {:type :reader-exception, :ex-kind :reader-error, :file nil, :line 45, :col 28}
; 	at clojure.tools.reader.impl.errors$throw_ex.invokeStatic(errors.clj:34)
; 	at clojure.tools.reader.impl.errors$throw_ex.doInvoke(errors.clj:24)
; 	at clojure.lang.RestFn.invoke(RestFn.java:442)
; 	at clojure.tools.reader.impl.errors$reader_error.invokeStatic(errors.clj:40)
; 	at clojure.tools.reader.impl.errors$reader_error.doInvoke(errors.clj:36)
; 	at clojure.lang.RestFn.invoke(RestFn.java:516)
; 	at clojure.tools.reader.impl.errors$throw_invalid.invokeStatic(errors.clj:97)
; 	at clojure.tools.reader.impl.errors$throw_invalid.invoke(errors.clj:96)
; 	at clojure.tools.reader$read_keyword.invokeStatic(reader.clj:358)
; 	at clojure.tools.reader$read_keyword.invoke(reader.clj:344)
; 	at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:935)
; 	at clojure.tools.reader$read_STAR_.invoke(reader.clj:917)
; 	at clojure.tools.reader$read_delimited.invokeStatic(reader.clj:198)
; 	at clojure.tools.reader$read_delimited.invoke(reader.clj:191)
; 	at clojure.tools.reader$read_list.invokeStatic(reader.clj:209)
; 	at clojure.tools.reader$read_list.invoke(reader.clj:205)
; 	at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:935)
; 	at clojure.tools.reader$read_STAR_.invoke(reader.clj:917)
; 	at clojure.tools.reader$read_delimited.invokeStatic(reader.clj:198)
; 	at clojure.tools.reader$read_delimited.invoke(reader.clj:191)
; 	at clojure.tools.reader$read_list.invokeStatic(reader.clj:209)
; 	at clojure.tools.reader$read_list.invoke(reader.clj:205)
; 	at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:935)
; 	at clojure.tools.reader$read_STAR_.invoke(reader.clj:917)
; 	at clojure.tools.reader$read_suppress.invokeStatic(reader.clj:451)
; 	at clojure.tools.reader$read_suppress.invoke(reader.clj:447)
; 	at clojure.tools.reader$match_feature.invokeStatic(reader.clj:474)
; 	at clojure.tools.reader$match_feature.invoke(reader.clj:458)
; 	at clojure.tools.reader$read_cond_delimited$fn__8556.invoke(reader.clj:485)
; 	at clojure.tools.reader$read_cond_delimited.invokeStatic(reader.clj:480)
; 	at clojure.tools.reader$read_cond_delimited.invoke(reader.clj:477)
; 	at clojure.tools.reader$read_cond.invokeStatic(reader.clj:522)
; 	at clojure.tools.reader$read_cond.invoke(reader.clj:506)
; 	at clojure.tools.reader$read_dispatch.invokeStatic(reader.clj:72)
; 	at clojure.tools.reader$read_dispatch.invoke(reader.clj:68)
; 	at clojure.tools.reader$read_STAR_.invokeStatic(reader.clj:935)
; 	at clojure.tools.reader$read_STAR_.invoke(reader.clj:917)
; 	at clojure.tools.reader$read.invokeStatic(reader.clj:988)
; 	at clojure.tools.reader$read.invoke(reader.clj:961)
&lt;/code&gt;&lt;/pre&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</guid>
<pubDate>Fri, 03 Nov 2023 20:57:26 +0000</pubDate>
</item>
<item>
<title>Location data on all IObj</title>
<link>https://ask.clojure.org/index.php/13314/location-data-on-all-iobj</link>
<description>&lt;p&gt;Only lists carry location data, even though most non-primitives implement IObj. Is there a reason for this? Would there be interest in adding location data to all IObj objects at read time?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (meta '(1 2 3))
{:line 1, :column 8}
user=&amp;gt; (meta 'abc)
nil
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13314/location-data-on-all-iobj</guid>
<pubDate>Wed, 20 Sep 2023 14:02:59 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;When setting &lt;code&gt;*default-data-reader-fn*&lt;/code&gt; to &lt;code&gt;tagged-literal&lt;/code&gt; (as suggested in &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/reader#_default_data_reader_function&quot;&gt;https://clojure.org/reference/reader#_default_data_reader_function&lt;/a&gt;) in a REPL like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (set! *default-data-reader-fn* tagged-literal)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As advertised, the REPL can now read unknown tagged literals, e.g.:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; #foo 123
#foo 123
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, it fails when embedded in an expresson like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (prn #foo 123)
Syntax error compiling fn* at (REPL:1:1).
Can't embed object in code, maybe print-dup not defined: clojure.lang.TaggedLiteral@34b5d34f
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The hint in the error message works indeed, so when I provide:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (defmethod print-dup clojure.lang.TaggedLiteral [tl w] (print-method tl w))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The REPL can now successfully read and eval the previous expression:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (prn #foo 123)
#foo 123
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Should the &lt;code&gt;print-dup&lt;/code&gt; implementation for &lt;code&gt;clojure.lang.TaggedLiteral&lt;/code&gt; perhaps be provided by default?&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</guid>
<pubDate>Tue, 12 Sep 2023 15:50:14 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;I've &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/10225/problem-using-numbers-as-keywords?show=10225#q10225&quot;&gt;read&lt;/a&gt; that the Clojure reader allows reading of numeric keywords because it would cause breaking changes in some libraries to change it, so it seems keywords were not intended to be used in that way. However, is there a breaking reason to not allow the name part of a qualified keyword to be numeric? Since numeric keywords are already being used/allowed?&lt;/p&gt;
&lt;p&gt;Use-Case:&lt;/p&gt;
&lt;p&gt;I've been playing with modeling in Datomic which encourages namespaced things (that aren't really namespaced) and went with enums for US State FIPS codes since that's what we work with over state names and don't need more than that, i.e., &lt;code&gt;:state/01&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This works&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(name :01) 
=&amp;gt; &quot;01&quot;

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt; But this doesn't&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(name :state/01)
=&amp;gt; Invalid token: :state/01
&lt;/code&gt;&lt;/pre&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</guid>
<pubDate>Fri, 27 Jan 2023 14:40:36 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;My code :&lt;/p&gt;
&lt;p&gt;(defn loadData [filename]&lt;br&gt;
  (with-open [rdr (io/reader filename)]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(doseq [line (line-seq rdr)
        :let [ [id &amp;amp; data]
              (clojure.string/split line #&quot;\|&quot;)] ]
            [
                (Integer/parseInt id) 
                data 
              ])
  
  ))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My file's content:&lt;/p&gt;
&lt;p&gt;1|Xxx|info1|222-2222&lt;br&gt;
2|Yyy|info2|333-3333&lt;br&gt;
3|Zzz|info3|444-4444&lt;/p&gt;
&lt;p&gt;How do I get this function to return a list like :&lt;br&gt;
{&lt;br&gt;
  {1, Xxx, info1, 222-2222}&lt;br&gt;
  {2, Yyy, info2, 333-3333}&lt;br&gt;
  {3, Zzz, info3, 444-4444}&lt;br&gt;
}&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</guid>
<pubDate>Thu, 08 Dec 2022 22:11:18 +0000</pubDate>
</item>
<item>
<title>should `clojure.core/=` have a zero arity?</title>
<link>https://ask.clojure.org/index.php/12441/should-clojure-core-have-a-zero-arity</link>
<description>&lt;p&gt;&lt;code&gt;=&lt;/code&gt; has a single arity returning true. Should it also have a 0 arity returning true as well?&lt;/p&gt;
&lt;p&gt;This would be in line with the results of &lt;code&gt;(and)&lt;/code&gt;, &lt;code&gt;(or)&lt;/code&gt;, &lt;code&gt;(every? odd [])&lt;/code&gt;. And would make &lt;code&gt;(apply = coll)&lt;/code&gt; safe in all cases, even when &lt;code&gt;coll&lt;/code&gt; was empty.&lt;/p&gt;
&lt;p&gt;From slack:&lt;br&gt;
&amp;gt; Agreed - I had an &lt;code&gt;#(-&amp;gt;&amp;gt; xs ... (apply =))&lt;/code&gt; in a fdef spec and it was failing in the case when xs is empty, forcing me to write a more verbose function.&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</guid>
<pubDate>Thu, 08 Dec 2022 16:50:28 +0000</pubDate>
</item>
<item>
<title>Complete beginner - questions about formatting, structure etc...</title>
<link>https://ask.clojure.org/index.php/12418/complete-beginner-questions-about-formatting-structure-etc</link>
<description>&lt;p&gt;Hello! I'm sorry if this is the wrong forum to start a thread like this, but I am new to Clojure/lisps in general and thought I would take this year's &lt;a rel=&quot;nofollow&quot; href=&quot;https://adventofcode.com&quot;&gt;Advent of Code (2022)&lt;/a&gt; as an opportunity to challenge myself to learn a bit.&lt;/p&gt;
&lt;p&gt;So I've started Day 1 and solved the problem (in essence, &lt;em&gt;Given a long list of double space separated numbers, find the largest sum amongst them&lt;/em&gt;) but with what looks like the most inelegant thrashing of how one might approach the problem in Clojure.&lt;/p&gt;
&lt;p&gt;For example, the answer for the following would be &lt;code&gt;300&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;10
20

100
200
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My solution is as follows, and I am wondering primarily:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Is this a reasonable approach to the problem, as a beginner, what am I missing out on that would be more elegant.&lt;/li&gt;
&lt;li&gt;How does one even format a line like this?&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;(Spoiler below, in case anyone else is interested in the challenge)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(require '[clojure.string :as str])

(reduce max (map (fn [x] (reduce + (map #(Integer/parseInt %) (str/split x #&quot;\n&quot;)))) (str/split (slurp &quot;./input-1.txt&quot;) #&quot;\n\n&quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I'm hoping, time permitting, to be able to continue this journey through the month so hopefully I'm able to as the challenges do become quite complicated even for languages I'm familiar with, but I can already say the REPL is really a wonderful thing.&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</guid>
<pubDate>Thu, 01 Dec 2022 11:51:35 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;When defining vars, we can provide docstrings in between the symbol and the binding. e.g. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def some-var 
  &quot;this var serves as an example&quot; 
  42)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, we cannot currently do so with &lt;code&gt;defonce&lt;/code&gt;. We must resort to providing metadata manually as follows.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defonce 
  ^{:doc &quot;this var serves as another example&quot;}
  other-example nil)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It would be nice to be able to use docstrings like we can in &lt;code&gt;def&lt;/code&gt;, &lt;code&gt;defn&lt;/code&gt;, etc. in a future release of Clojure.&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</guid>
<pubDate>Sat, 29 Oct 2022 00:58:01 +0000</pubDate>
</item>
<item>
<title>Read-time evaluation of macros causes errors</title>
<link>https://ask.clojure.org/index.php/12296/read-time-evaluation-of-macros-causes-errors</link>
<description>&lt;p&gt;Read-time evaluation of functions work as expected. For instance, submitting &lt;code&gt;#=(+ 1 1)&lt;/code&gt; to the REPL will indeed return &lt;code&gt;2&lt;/code&gt;. However, read-time evaluation forms such as &lt;code&gt;(if true 1 0)&lt;/code&gt; will produce an error. The errors reported are not consistent across macros and special forms.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#=(if true 1 0)
;;=&amp;gt; Can't resolve if
#=(let [] nil)
;;=&amp;gt; Wrong number of args (2) passed to: clojure.core/let
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this expected behavior? Languages like Common Lisp do not produce errors in this scenario--e.g. the code &lt;code&gt;#.(if t 1 0)&lt;/code&gt; returns &lt;code&gt;1&lt;/code&gt;.&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</guid>
<pubDate>Tue, 11 Oct 2022 04:00:39 +0000</pubDate>
</item>
<item>
<title>improve syntax errors on tagged-literals</title>
<link>https://ask.clojure.org/index.php/12256/improve-syntax-errors-on-tagged-literals</link>
<description>&lt;p&gt;When we write a symbol in the UUID literal, the reported error message is wrong&lt;/p&gt;
&lt;p&gt;(as of 1.11.1)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clojure -M -e '#uuid id'
Execution error (AssertionError) at clojure.main/main (main.java:40).
Assert failed: (string? form)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It is wrong because&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;It is not an execution error. Should be read or syntax error.&lt;/li&gt;
&lt;li&gt;It does not include any ex-data: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/repl_and_main#_error_printing&quot;&gt;https://clojure.org/reference/repl_and_main#_error_printing&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It should be something like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Reader error (AssertionError) at clojure.uuid/default-uuid-reader (uuid.clj:12).
Assert failed: (string? form)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A second step improvement could be add spec support to data-literals, as macros do.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Syntax error reading #uuid id at (REPL:1)
id - failed: string? at: [:form]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;From #clojure-dev slack channel&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;Alex: You don’t need anything special there - just an instrumented spec on the data reader fn&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;After run&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(s/fdef clojure.uuid/default-uuid-reader :args (s/cat :form string?))
(clojure.spec.test.alpha/instrument `clojure.uuid/default-uuid-reader)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The message turns into&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Syntax error reading source at (REPL:2:1).
Call to #'clojure.uuid/default-uuid-reader did not conform to spec.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is a way better message.&lt;/p&gt;
&lt;p&gt;Also, it includes a &lt;code&gt;#:clojure.error{:phase :read-source}&lt;/code&gt; in ex-data.&lt;br&gt;
So the fix could be just add a spec to &lt;code&gt;clojure.uuid/default-uuid-reader&lt;/code&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</guid>
<pubDate>Wed, 28 Sep 2022 13:24:40 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;It's happen when i load the huqsql namespace into nREPL and then the error is appears to be something like this :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Syntax error (FileNotFoundException) compiling at (src/db_examples/hugsql.clj:1:1).
Could not locate hugsql/core__init.class, hugsql/core.clj or hugsql/core.cljc on classpath.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;dependencies :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[[org.clojure/clojure &quot;1.10.1&quot;]
             [seancorfield/next.jdbc &quot;1.1.613&quot;]
             [org.postgresql/postgresql &quot;42.2.8&quot;]
             [com.layerware/hugsql &quot;0.5.3&quot;]
             [hugsql-next-jdbc &quot;0.1.3&quot;]]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the namespace :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns db-examples.hugsql

(:require [db-examples.core :refer [db]]
            [next.jdbc :as jdbc]
            [hugsql.core :as hugsql]))

(hugsql/def-db-fns &quot;resources/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</guid>
<pubDate>Mon, 26 Sep 2022 16:46:09 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;I open a file, type in (map prn (range 2)) then save the file and execute clojure file.clj.&lt;br&gt;
This produces no output.&lt;br&gt;
I then execute clojure and type in (map prn (range 2)).&lt;br&gt;
This produces output.&lt;/p&gt;
&lt;p&gt;Is there some kind of &quot;feature&quot; of clojure that discards code within for and map if the result is not used when you run it on a file?&lt;br&gt;
If that is the case, presumably it should give an error or at least a warning that there is dead code that it is discarding.&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</guid>
<pubDate>Sat, 25 Jun 2022 01:27:29 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;Currently, Clojure allows for destructuring patterns that contain &amp;amp;rest arguments:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (let [[a b &amp;amp; c] (range 5)] [a b c])
[0 1 (2 3 4)]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Python allows for the same, but also for placing the so-called catch-all in the front and middle position as well (&lt;a rel=&quot;nofollow&quot; href=&quot;https://peps.python.org/pep-3132/&quot;&gt;PEP description&lt;/a&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a, *b, c = range(5)
&amp;gt;&amp;gt;&amp;gt; a
0
&amp;gt;&amp;gt;&amp;gt; c
4
&amp;gt;&amp;gt;&amp;gt; b
[1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Has similar been considered for Clojure? Could look like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (let [[a &amp;amp; b c] (range 5)] [a b c])
[0 (1 2 3) 4]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I feel like this would be doable with how the core functions destructure currently works, but it’s possible I don’t know some subtlety. &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</guid>
<pubDate>Mon, 20 Jun 2022 13:23:18 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;(= (map :name (mapify (parse (slurp filename)))) '(&quot;Edward Cullen&quot; &quot;Bella Swan&quot; &quot;Charlie Swan&quot; &quot;Jacob Black&quot; &quot;Carlisle Cullen&quot; &quot;Joni balap&quot;))&lt;br&gt;
=&amp;gt; true&lt;/p&gt;
&lt;p&gt;(clojure.string/includes? (map :name (mapify (parse (slurp filename)))) &quot;Joni&quot;)&lt;br&gt;
=&amp;gt; false&lt;/p&gt;
&lt;p&gt;(clojure.string/includes? '(&quot;Edward Cullen&quot; &quot;Bella Swan&quot; &quot;Charlie Swan&quot; &quot;Jacob Black&quot; &quot;Carlisle Cullen&quot; &quot;Joni balap&quot;) &quot;Joni&quot;)&lt;br&gt;
=&amp;gt; true&lt;/p&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</guid>
<pubDate>Mon, 13 Jun 2022 20:21:16 +0000</pubDate>
</item>
<item>
<title>atom value different results</title>
<link>https://ask.clojure.org/index.php/11941/atom-value-different-results</link>
<description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;(def cnt (atom 0))&lt;br&gt;
(defn up[] (swap! cnt #(inc %)))&lt;br&gt;
(defn down[] (swap! cnt #(dec %)))&lt;br&gt;
(defn shift-by[offset] (swap! cnt #(+ % offset)))&lt;br&gt;
(dotimes [_ 10] (up))&lt;br&gt;
(println &quot;cnt up =&amp;gt; &quot; @cnt)&lt;br&gt;
(loop [i 0] (if (&amp;lt; i 10) (do (down)(recur (inc i)))))&lt;br&gt;
(println &quot;cnt down =&amp;gt; &quot; @cnt)&lt;br&gt;
(def cnt' (for[i (range 5)] (shift-by i)))&lt;br&gt;
(println &quot;cnt shift1 =&amp;gt; &quot; @cnt)&lt;br&gt;
(println &quot;cnt' =&amp;gt; &quot; cnt')&lt;br&gt;
(println &quot;cnt shift2 =&amp;gt; &quot; @cnt)&lt;/p&gt;
&lt;p&gt;cnt up =&amp;gt;  10&lt;br&gt;
cnt down =&amp;gt;  0&lt;br&gt;
cnt shift1 =&amp;gt;  0&lt;br&gt;
cnt' =&amp;gt;  (0 1 3 6 10)&lt;br&gt;
cnt shift2 =&amp;gt;  10&lt;/p&gt;
&lt;p&gt;why is shift1 shows 0 and shift2 show 10?&lt;/p&gt;
&lt;p&gt;Regards,&lt;br&gt;
Daniel&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11941/atom-value-different-results</guid>
<pubDate>Fri, 03 Jun 2022 20:19:02 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;Hello dear Clojurians!&lt;br&gt;
What is the difference between &quot;keyword&quot; and &quot;atom&quot;?&lt;br&gt;
Sorry, I'm a total newbie  :-)&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</guid>
<pubDate>Fri, 22 Apr 2022 16:42:02 +0000</pubDate>
</item>
<item>
<title>java interop, property same name as object</title>
<link>https://ask.clojure.org/index.php/11618/java-interop-property-same-name-as-object</link>
<description>&lt;p&gt;Hi all, &lt;/p&gt;
&lt;p&gt;java pubilc class A has public proprety int a; when (def a(A.)) and then (.a a) the error A (wrong name :a) is shown. &lt;/p&gt;
&lt;p&gt;Why is that?&lt;/p&gt;
&lt;p&gt;[edit]&lt;/p&gt;
&lt;p&gt;// silly example to demonstrate access patterns to A from clojure&lt;/p&gt;
&lt;p&gt;public class A {&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;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; }
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;}&lt;/p&gt;
&lt;p&gt;$ javac A.java&lt;br&gt;
$ clojure -cp &quot;.&quot;&lt;br&gt;
user =&amp;gt; (import A)&lt;br&gt;
user =&amp;gt; (def a (A.))&lt;br&gt;
user =&amp;gt; (def x (A.))&lt;br&gt;
user =&amp;gt; (def a1 (A.))&lt;br&gt;
user =&amp;gt; (.a a1)&lt;br&gt;
1&lt;br&gt;
user =&amp;gt; (.a x)&lt;br&gt;
1&lt;br&gt;
user =&amp;gt; (.a a)&lt;br&gt;
Execution error (NoClassDefFoundError) at java.lang.ClassLoader/defineClass1 (ClassLoader.java:-2).&lt;br&gt;
A (wrong name: a)&lt;/p&gt;
&lt;p&gt;;; why a is not allowed?&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</guid>
<pubDate>Fri, 11 Mar 2022 14:37:43 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;The if-not macro is implemented as:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defmacro if-not
  &quot;Evaluates test. If logical false, evaluates and returns then expr, 
  otherwise else expr, if supplied, else nil.&quot;
  {:added &quot;1.0&quot;}
  ([test then] `(if-not ~test ~then nil))
  ([test then else]
   `(if (not ~test) ~then ~else)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The first form expands to the second, and the second uses &lt;code&gt;not&lt;/code&gt;, so if I simplify by removing docs and the other arity, we effectively get:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defmacro if-not
  [test then else]
  `(if (if ~test false true) then else))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This seems like more work than just reversing the forms. I had assumed that this would instead be:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defmacro if-not
  &quot;Evaluates test. If logical false, evaluates and returns then expr, 
  otherwise else expr, if supplied, else nil.&quot;
  {:added &quot;1.0&quot;}
  ([test then] `(if-not ~test ~then nil))
  ([test then else]
   `(if ~test ~else ~then)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I appreciate that it's not a big deal, but is there a reason for using &lt;code&gt;not&lt;/code&gt; and not just inverting the forms?&lt;/p&gt;
&lt;p&gt;PS. I believe this question may have been asked before, but I’ve been searching ask.clojure and can’t find it.&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</guid>
<pubDate>Fri, 21 Jan 2022 18:18:24 +0000</pubDate>
</item>
<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'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: #'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't know why it'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>
<item>
<title>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</link>
<description>&lt;p&gt;Clojure's &lt;code&gt;any?&lt;/code&gt; function seems to just return &lt;code&gt;true&lt;/code&gt; always.&lt;br&gt;
&lt;code&gt;(defn any?
  &quot;Returns true given any argument.&quot;
  {:tag Boolean
   :added &quot;1.9&quot;}
  [x] true)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Contrast this with &lt;code&gt;not-any?&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;(def
 ^{:tag Boolean
   :doc &quot;Returns false if (pred x) is logical true for any x in coll,
  else true.&quot;
   :arglists '([pred coll])
   :added &quot;1.0&quot;}
 not-any? (comp not some))&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I believe &lt;code&gt;any?&lt;/code&gt; should take two arguments and return &lt;code&gt;true&lt;/code&gt; if any predicate is &lt;code&gt;true&lt;/code&gt;.&lt;br&gt;
&lt;code&gt;(def
 ^{:tag Boolean
   :doc &quot;Returns true if (pred x) is logical true for any x in coll,
  else false.&quot;
   :arglists '([pred coll])
   :added &quot;1.9&quot;}
 any? (comp boolean some))&lt;/code&gt;&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojuredocs.org/clojure.core/any_q&quot;&gt;Credit to Kofrasa on ClojureDocs.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here are some tests to run:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(ns user&lt;br&gt;
  (:require [clojure.test :refer [are deftest]]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;        [clojure.test.check.clojure-test :refer [defspec]]
        [clojure.test.check.generators :as gen]
        [clojure.test.check.properties :as prop])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;  (:refer-clojure :exclude [any?]))&lt;/p&gt;
&lt;p&gt;(deftest clojure-any&lt;br&gt;
  (are [x y] (= ((comp boolean some) true? x) (clojure.core/any? y))&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[true] true
[false] false ;; this fails
[true true] true
[false true] true
[false false] false ;; so does this
))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(def&lt;br&gt;
 ^{:tag Boolean&lt;br&gt;
   :doc &quot;Returns true if (pred x) is logical true for any x in coll,&lt;br&gt;
  else false.&quot;&lt;br&gt;
   :arglists '([pred coll])&lt;br&gt;
   :added &quot;1.9&quot;}&lt;br&gt;
 any? (comp boolean some))&lt;/p&gt;
&lt;p&gt;(defspec correct-any 1000&lt;br&gt;
  (prop/for-all [v (gen/such-that not-empty (gen/vector gen/boolean))]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;            (= ((comp boolean some) true? v)
               (any? true? v)
               (not (not-any? true? v)))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Apologies for the messed-up formatting.&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/wildwestrom/9568e9c659d30a2a663a9a0a8235a6b9&quot;&gt;https://gist.github.com/wildwestrom/9568e9c659d30a2a663a9a0a8235a6b9&lt;/a&gt;&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</guid>
<pubDate>Tue, 09 Nov 2021 22:30:57 +0000</pubDate>
</item>
<item>
<title>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</link>
<description>&lt;p&gt;related to a thread on clojureverse: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojureverse.org/t/x-x-auto-transducifying-thread-macros/8122/26&quot;&gt;https://clojureverse.org/t/x-x-auto-transducifying-thread-macros/8122/26&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;,where the author's library provides a transducerized variant of -&amp;gt;&amp;gt; called x&amp;gt;&amp;gt; that recog,nizes transducers and tries to turn the threading expression into an efficient transducer form.&lt;/p&gt;
&lt;p&gt;The author then decided to fold in keyword-access semantics for strings and numbers, to enable threaded expressions that equate to &lt;code&gt;get&lt;/code&gt; or &lt;code&gt;get-in&lt;/code&gt; with less verbosity.  Something like &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [m {1 {&quot;b&quot; [0 1 {:c :res}]}}]
     (x&amp;gt; m 1 &quot;b&quot; 2 :c name)) ;=&amp;gt; &quot;res&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which is akin to the keyword idiom of &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(-&amp;gt; m :a :b :c) ;;some-nested-value
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is there any reason why in the general case, &lt;code&gt;eval&lt;/code&gt; should not support keyword access semantics for other simple types like numbers and strings (maybe booleans, whatever)?&lt;br&gt;
Aside from being unable to extend IFn to strings and numbers (this would have to be handled with additional type checks dispatching on the first arg instead of focusing on IFn), are there language design arguments against this?  I am unable to derive any off the top of my head.&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</guid>
<pubDate>Wed, 08 Sep 2021 20:24:28 +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>
</channel>
</rss>