<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged problem</title>
<link>https://ask.clojure.org/index.php/tag/problem</link>
<description></description>
<item>
<title>linux installer fails for non english locale</title>
<link>https://ask.clojure.org/index.php/15081/linux-installer-fails-for-non-english-locale</link>
<description>&lt;p&gt;&quot;OK&quot; returned by &lt;code&gt;sha256sum&lt;/code&gt; may be translated. Better rely on the exit status. Since &lt;code&gt;-p pipefail&lt;/code&gt; is used, the pipe to &lt;code&gt;grep&lt;/code&gt; could be simply omitted.&lt;/p&gt;
</description>
<category>Tools</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15081/linux-installer-fails-for-non-english-locale</guid>
<pubDate>Thu, 14 May 2026 20:48:19 +0000</pubDate>
</item>
<item>
<title>Installing Clojure on IPv6-only machine</title>
<link>https://ask.clojure.org/index.php/15051/installing-clojure-on-ipv6-only-machine</link>
<description>&lt;p&gt;Since GitHub (still) do not support IPv6 it is not possible to follow the instructions at &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/guides/install_clojure&quot;&gt;https://clojure.org/guides/install_clojure&lt;/a&gt; (for Linux, say) to install the Clojure CLI on a machine running ONLY IPv6 (in this case Hertzner).&lt;/p&gt;
&lt;p&gt;When downloading the .tar.gz-file manally and uploading it directly, installing the CLI tools is possilbe.&lt;/p&gt;
&lt;p&gt;The problems seem to continue installing common clojure dependencies, like data.json 2.5.2, which leads to this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj -X:server
Error building classpath. Failed to read artifact descriptor for org.clojure:data.json:jar:2.5.2
org.eclipse.aether.resolution.ArtifactDescriptorException: Failed to read artifact descriptor for org.clojure:data.json:jar:2.5.2
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.loadPom(DefaultArtifactDescriptorReader.java:255)
	at org.apache.maven.repository.internal.DefaultArtifactDescriptorReader.readArtifactDescriptor(DefaultArtifactDescriptorReader.java:171)
	at org.eclipse.aether.internal.impl.DefaultRepositorySystem.readArtifactDescriptor(DefaultRepositorySystem.java:263)
	at clojure.tools.deps.extensions.maven$read_descriptor.invokeStatic(maven.clj:115)
	at clojure.tools.deps.extensions.maven$fn__1340.invokeStatic(maven.clj:143)
	at clojure.tools.deps.extensions.maven$fn__1340.invoke(maven.clj:143)
	at clojure.lang.MultiFn.invoke(MultiFn.java:244)
	at clojure.tools.deps$expand_deps$children_task__959$fn__961$fn__962.invoke(deps.clj:299)
    ...
Caused by: java.net.SocketException: Network is unreachable
at java.base/sun.nio.ch.Net.connect0(Native Method)
at java.base/sun.nio.ch.Net.connect(Net.java:546)
at java.base/sun.nio.ch.Net.connect(Net.java:535)
at java.base/sun.nio.ch.NioSocketImpl.connect(NioSocketImpl.java:585)
at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.jar
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;All this seem a bit bisarre of course. Workarounds would make me happy!&lt;/p&gt;
</description>
<category>Tools</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15051/installing-clojure-on-ipv6-only-machine</guid>
<pubDate>Fri, 24 Apr 2026 23:21:53 +0000</pubDate>
</item>
<item>
<title>false positive warning: &quot;cljs.core/+, all arguments must be numbers&quot;</title>
<link>https://ask.clojure.org/index.php/14870/false-positive-warning-cljs-core-all-arguments-must-numbers</link>
<description>&lt;p&gt;The &lt;code&gt;inc&lt;/code&gt; function below will never receive a nil, but falsely warns that it might:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj -Sdeps '{:deps {org.clojure/clojurescript {:mvn/version &quot;1.12.134&quot;}}}' -M -m cljs.main -re node
ClojureScript 1.12.134

cljs.user=&amp;gt; (some-&amp;gt; 1 (#(when (pos? %) %)) inc)
WARNING: cljs.core/+, all arguments must be numbers, got [#{nil clj-nil} number] instead at line 1 &amp;lt;cljs repl&amp;gt;
2
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14870/false-positive-warning-cljs-core-all-arguments-must-numbers</guid>
<pubDate>Tue, 06 Jan 2026 16:51:22 +0000</pubDate>
</item>
<item>
<title>Why does the REPL incorrectly display my command after I press enter?</title>
<link>https://ask.clojure.org/index.php/14848/why-does-repl-incorrectly-display-command-after-press-enter</link>
<description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I'm having a small bug with the Clojure REPL - when I enter a command, after pressing the enter key, the command gets displayed incorrectly - basically the beginning of the text of the command that I entered is displayed for the first few characters, and then everything after that is overwritten with the same text of the command displayed with an indentation.&lt;/p&gt;
&lt;p&gt;Not sure if that's very clear, so I've added a pair of screenshots, &quot;before and after&quot;, to illustrate.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://arielche.net/clojurereplbugbefore.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://arielche.net/clojurereplbugafter.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
&lt;p&gt;This issue seems similar to &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/10025/have-prompts-previous-lines-command-started-disappearing&quot;&gt;this older question&lt;/a&gt;, although in that case the issue was with the &lt;code&gt;rlwrap&lt;/code&gt; library, which was patched afterwards.&lt;/p&gt;
&lt;p&gt;Is there a way to fix this?&lt;/p&gt;
</description>
<category>REPL</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14848/why-does-repl-incorrectly-display-command-after-press-enter</guid>
<pubDate>Mon, 22 Dec 2025 15:01:06 +0000</pubDate>
</item>
<item>
<title>`(max &quot;x&quot; &quot;y&quot;)` used to return &quot;y&quot;, now it returns &quot;x&quot;</title>
<link>https://ask.clojure.org/index.php/14847/max-x-y-used-to-return-y-now-it-returns-x</link>
<description>&lt;p&gt;Hello!&lt;/p&gt;
&lt;p&gt;With cljs 1.12.42:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cljs.user=&amp;gt; (max &quot;x&quot; &quot;y&quot;)
&quot;y&quot;
cljs.user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;With cljs 1.12.134:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cljs.user=&amp;gt; (max &quot;x&quot; &quot;y&quot;)
&quot;x&quot;
cljs.user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Probably related to &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJS-3425&quot;&gt;CLJS-3425&lt;/a&gt; and &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojurescript/commit/274701280de787b598071460cdac0a3709a5bc11&quot;&gt;this commit&lt;/a&gt; which added &lt;code&gt;NaN&lt;/code&gt; checks:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn ^number max
  &quot;Returns the greatest of the nums.&quot;
  ([x] x)
  ([x y]
   (cond
     (NaN? x) x
     (NaN? y) y
     (&amp;gt; x y) x
     :else y))
  ([x y &amp;amp; more]
   (reduce max (cljs.core/max x y) more)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;cljs.user=&amp;gt; (NaN? &quot;x&quot;)
true
cljs.user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hence the result.&lt;/p&gt;
&lt;p&gt;Not sure what the expected result should be since min/max are only supposed to work with numbers but current behavior is surprising.&lt;/p&gt;
&lt;p&gt;See also: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/jank-lang/clojure-test-suite/pull/839&quot;&gt;https://github.com/jank-lang/clojure-test-suite/pull/839&lt;/a&gt;.&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14847/max-x-y-used-to-return-y-now-it-returns-x</guid>
<pubDate>Mon, 22 Dec 2025 13:45:04 +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>bug   bigdec</title>
<link>https://ask.clojure.org/index.php/14809/bug-bigdec</link>
<description>&lt;p&gt;&lt;img src=&quot;https://mysys-images.oss-cn-beijing.aliyuncs.com/clojure-bigdec.png&quot; alt=&quot;&quot;&gt;&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14809/bug-bigdec</guid>
<pubDate>Fri, 05 Dec 2025 05:09:44 +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>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>Docstring clojure.edn/read-string is misleading</title>
<link>https://ask.clojure.org/index.php/14762/docstring-clojure-edn-read-string-is-misleading</link>
<description>&lt;blockquote&gt;&lt;p&gt;  user=&amp;gt; (doc clojure.edn/read-string)&lt;br&gt;
  -------------------------&lt;br&gt;
  clojure.edn/read-string&lt;br&gt;
  ([s] [opts s])&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Reads one object from the string s. Returns nil when s is nil or empty.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;   Reads data in the edn format (subset of Clojure data):&lt;br&gt;
   &lt;a rel=&quot;nofollow&quot; href=&quot;http://edn-format.org&quot;&gt;http://edn-format.org&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;   opts is a map as per clojure.edn/read&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Note &lt;strong&gt;Returns nil when s is nil or empty.&lt;/strong&gt;. But when called with opts without explicit :eof it throws EOF error&lt;/p&gt;
&lt;p&gt;user=&amp;gt; (clojure.edn/read-string {} &quot;&quot;)&lt;br&gt;
Execution error at user/eval222 (REPL:1).&lt;br&gt;
EOF while reading&lt;/p&gt;
&lt;p&gt;And without options it returns nil as expected&lt;/p&gt;
&lt;p&gt;user=&amp;gt; (clojure.edn/read-string &quot;&quot;)&lt;br&gt;
nil&lt;/p&gt;
</description>
<category>Docs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14762/docstring-clojure-edn-read-string-is-misleading</guid>
<pubDate>Thu, 20 Nov 2025 15:10:38 +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>flow monitoring tool serves resources from unqualified path</title>
<link>https://ask.clojure.org/index.php/14748/flow-monitoring-tool-serves-resources-from-unqualified-path</link>
<description>&lt;p&gt;For flow monitoring, HTML, CSS, and javascript assets are served from the resource path &quot;public/&quot;. If there is another library on the classpath that also has a resource at &quot;public/index.html&quot;, then flow monitoring's assets will get clobbered and serve the wrong web page instead. Alternatively, flow monitoring may clobber someone else's resources.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async.flow-monitor/blob/6248a5d8e4228ab5974289559e3cb11ff3152263/src/clojure/core/async/flow_monitor.clj#L104&quot;&gt;https://github.com/clojure/core.async.flow-monitor/blob/6248a5d8e4228ab5974289559e3cb11ff3152263/src/clojure/core/async/flow_monitor.clj#L104&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;This can be addressed by moving resources to a qualified path like &quot;clojure/core/async/flow_monitor/public/index.html&quot;.&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14748/flow-monitoring-tool-serves-resources-from-unqualified-path</guid>
<pubDate>Tue, 04 Nov 2025 20:57:47 +0000</pubDate>
</item>
<item>
<title>`pipeline-blocking` uses `thread` internally instead of `io-thread`</title>
<link>https://ask.clojure.org/index.php/14738/pipeline-blocking-uses-thread-internally-instead-of-thread</link>
<description>&lt;p&gt;&lt;code&gt;pipeline-blocking&lt;/code&gt; is explicitly meant for blocking operations (implying I/O). However, internally it uses &lt;code&gt;thread&lt;/code&gt; rather than &lt;code&gt;io-thread&lt;/code&gt; for processing: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L637-L640&quot;&gt;https://github.com/clojure/core.async/blob/master/src/main/clojure/clojure/core/async.clj#L637-L640&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Since 1.9.829-alpha2 this has practical implications, as only &lt;code&gt;io-thread&lt;/code&gt; will utilize virtual threads, when available.&lt;/p&gt;
&lt;p&gt;Can this be fixed / changed?&lt;br&gt;
If not, can an explicit &lt;code&gt;pipeline-io&lt;/code&gt; (or similar)  function be added to support this use case?&lt;/p&gt;
&lt;p&gt;Thanks&lt;/p&gt;
</description>
<category>core.async</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14738/pipeline-blocking-uses-thread-internally-instead-of-thread</guid>
<pubDate>Wed, 29 Oct 2025 15:54:00 +0000</pubDate>
</item>
<item>
<title>Typo in clojure.zipper/zipper docstring</title>
<link>https://ask.clojure.org/index.php/14733/typo-in-clojure-zipper-zipper-docstring</link>
<description>&lt;p&gt;The docstring for &lt;code&gt;clojure.zipper/zipper&lt;/code&gt; currently contains:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;branch? is a fn that, given a node, returns true if can have&lt;br&gt;
children, even if it currently doesn't.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;which should be:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;branch? is a fn that, given a node, returns true if it can have&lt;br&gt;
children, even if it currently doesn't.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
<category>Docs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14733/typo-in-clojure-zipper-zipper-docstring</guid>
<pubDate>Mon, 27 Oct 2025 09:30:17 +0000</pubDate>
</item>
<item>
<title>Does cljr -Sdeps work for other people?</title>
<link>https://ask.clojure.org/index.php/14695/does-cljr-sdeps-work-for-other-people</link>
<description>&lt;p&gt;Putting the dependencies in a &lt;code&gt;deps-clr.edn&lt;/code&gt; file works.&lt;/p&gt;
&lt;p&gt;But not via &lt;code&gt;cljr -Sdeps&lt;/code&gt;. E.g.: try to launch nREPL server:&lt;br&gt;
&lt;code&gt;$ cljr -Sdeps '{:deps {io.github.clojure/clr.tools.nrepl {:git/tag &quot;v0.1.2-alpha2&quot;}}}' -X clojure.tools.nrepl/start-server!
Clojure core loaded in 4177 milliseconds.
Starting exec/tool
Clojure core loaded in 4207 milliseconds.
Namespace could not be loaded: clojure.tools.nrepl&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I did custom compile some things so wondering if it's just me. The README for clr.core.cli says -Sdeps is supported.&lt;/p&gt;
&lt;p&gt;I can malform the string and seems to throw no errors, I don't think it's being processed.&lt;/p&gt;
&lt;p&gt;Well I'll poke around and report back what I find meanwhile.&lt;/p&gt;
</description>
<category>ClojureCLR</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14695/does-cljr-sdeps-work-for-other-people</guid>
<pubDate>Mon, 01 Sep 2025 23:26:42 +0000</pubDate>
</item>
<item>
<title>Method with int parameter is called, although the provided parameter is long</title>
<link>https://ask.clojure.org/index.php/14612/method-with-parameter-called-although-provided-parameter</link>
<description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/LWJGL/lwjgl3/blob/3.3.6/modules/lwjgl/assimp/src/generated/java/org/lwjgl/assimp/AIMesh.java&quot;&gt;AIMesh&lt;/a&gt; provides several overloaded &lt;code&gt;create&lt;/code&gt; methods. There is one with an &lt;code&gt;int&lt;/code&gt; parameter and another one with a &lt;code&gt;long&lt;/code&gt; parameter. They have very different semantics.&lt;/p&gt;
&lt;p&gt;This code snippet intends to call the one with the &lt;code&gt;long&lt;/code&gt; parameter:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn read-model
  &quot;read a 3D model from a file&quot;
  [path]
  (let [scene (Assimp/aiImportFile path (bit-or Assimp/aiProcess_Triangulate
                                                Assimp/aiProcess_FlipUVs))]
    (if (= scene nil)
      (println (Assimp/aiGetErrorString))
      (for [index (range (.mNumMeshes scene))]
        (let [pointer (.get (.mMeshes scene) index)]
          (assert (= (type pointer) java.lang.Long))
          (AIMesh/create pointer))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The assertion right before the problematic call makes sure that &lt;code&gt;pointer&lt;/code&gt; is indeed a &lt;code&gt;long&lt;/code&gt;; but nevertheless the &lt;code&gt;int&lt;/code&gt; overload of &lt;code&gt;create&lt;/code&gt; is called, as can be verified in the stack trace:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:clojure.main/message
 &quot;Execution error (IllegalArgumentException) at java.nio.Buffer/createCapacityException (Buffer.java:290).\ncapacity &amp;lt; 0: (-689151616 &amp;lt; 0)\n&quot;,
 :clojure.main/triage
 {:clojure.error/class java.lang.IllegalArgumentException,
  :clojure.error/line 290,
  :clojure.error/cause &quot;capacity &amp;lt; 0: (-689151616 &amp;lt; 0)&quot;,
  :clojure.error/symbol java.nio.Buffer/createCapacityException,
  :clojure.error/source &quot;Buffer.java&quot;,
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type clojure.lang.Compiler$CompilerException,
    :message
    &quot;Syntax error macroexpanding at (learnopengl/core.clj:12:1).&quot;,
    :data
    {:clojure.error/phase :execution,
     :clojure.error/line 12,
     :clojure.error/column 1,
     :clojure.error/source &quot;learnopengl/core.clj&quot;},
    :at [clojure.lang.Compiler load &quot;Compiler.java&quot; 7665]}
   {:type java.lang.IllegalArgumentException,
    :message &quot;capacity &amp;lt; 0: (-689151616 &amp;lt; 0)&quot;,
    :at [java.nio.Buffer createCapacityException &quot;Buffer.java&quot; 290]}],
  :trace
  [[java.nio.Buffer createCapacityException &quot;Buffer.java&quot; 290]
   [java.nio.Buffer &amp;lt;init&amp;gt; &quot;Buffer.java&quot; 253]
   [java.nio.ByteBuffer &amp;lt;init&amp;gt; &quot;ByteBuffer.java&quot; 316]
   [java.nio.ByteBuffer &amp;lt;init&amp;gt; &quot;ByteBuffer.java&quot; 324]
   [java.nio.MappedByteBuffer &amp;lt;init&amp;gt; &quot;MappedByteBuffer.java&quot; 113]
   [java.nio.DirectByteBuffer &amp;lt;init&amp;gt; &quot;DirectByteBuffer.java&quot; 107]
   [java.nio.ByteBuffer allocateDirect &quot;ByteBuffer.java&quot; 360]
   [org.lwjgl.system.Struct __create &quot;Struct.java&quot; 118]
   [org.lwjgl.assimp.AIMesh create &quot;AIMesh.java&quot; 487]
   [jdk.internal.reflect.DirectMethodHandleAccessor
    invoke
    &quot;DirectMethodHandleAccessor.java&quot;
    103]
   [java.lang.reflect.Method invoke &quot;Method.java&quot; 580]
   [clojure.lang.Reflector invokeMatchingMethod &quot;Reflector.java&quot; 167]
   [clojure.lang.Reflector invokeStaticMethod &quot;Reflector.java&quot; 332]
   [learnopengl.mesh_model$read_model$iter__332__336$fn__337$fn__338
    invoke
    &quot;mesh_model.clj&quot;
    66]
   [learnopengl.mesh_model$read_model$iter__332__336$fn__337
    invoke
    &quot;mesh_model.clj&quot;
    63]
   [clojure.lang.LazySeq sval &quot;LazySeq.java&quot; 42]
   [clojure.lang.LazySeq seq &quot;LazySeq.java&quot; 51]
   [clojure.lang.RT seq &quot;RT.java&quot; 535]
   [clojure.lang.RT countFrom &quot;RT.java&quot; 650]
   [clojure.lang.RT count &quot;RT.java&quot; 643]
   [learnopengl.core$eval351 invokeStatic &quot;core.clj&quot; 12]
   [learnopengl.core$eval351 invoke &quot;core.clj&quot; 12]
   [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7194]
   [clojure.lang.Compiler load &quot;Compiler.java&quot; 7653]
   [clojure.lang.RT loadResourceScript &quot;RT.java&quot; 381]
   [clojure.lang.RT loadResourceScript &quot;RT.java&quot; 372]
   [clojure.lang.RT load &quot;RT.java&quot; 459]
   [clojure.lang.RT load &quot;RT.java&quot; 424]
   [clojure.core$load$fn__6908 invoke &quot;core.clj&quot; 6161]
   [clojure.core$load invokeStatic &quot;core.clj&quot; 6160]
   [clojure.core$load doInvoke &quot;core.clj&quot; 6144]
   [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 408]
   [clojure.core$load_one invokeStatic &quot;core.clj&quot; 5933]
   [clojure.core$load_one invoke &quot;core.clj&quot; 5928]
   [clojure.core$load_lib$fn__6850 invoke &quot;core.clj&quot; 5975]
   [clojure.core$load_lib invokeStatic &quot;core.clj&quot; 5974]
   [clojure.core$load_lib doInvoke &quot;core.clj&quot; 5953]
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 142]
   [clojure.core$apply invokeStatic &quot;core.clj&quot; 669]
   [clojure.core$load_libs invokeStatic &quot;core.clj&quot; 6016]
   [clojure.core$load_libs doInvoke &quot;core.clj&quot; 6000]
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 137]
   [clojure.core$apply invokeStatic &quot;core.clj&quot; 669]
   [clojure.core$require invokeStatic &quot;core.clj&quot; 6038]
   [clojure.core$require doInvoke &quot;core.clj&quot; 6038]
   [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 408]
   [user$eval140$fn__144 invoke &quot;form-init15974239925031016013.clj&quot; 1]
   [user$eval140 invokeStatic &quot;form-init15974239925031016013.clj&quot; 1]
   [user$eval140 invoke &quot;form-init15974239925031016013.clj&quot; 1]
   [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7194]
   [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7184]
   [clojure.lang.Compiler load &quot;Compiler.java&quot; 7653]
   [clojure.lang.Compiler loadFile &quot;Compiler.java&quot; 7591]
   [clojure.main$load_script invokeStatic &quot;main.clj&quot; 475]
   [clojure.main$init_opt invokeStatic &quot;main.clj&quot; 477]
   [clojure.main$init_opt invoke &quot;main.clj&quot; 477]
   [clojure.main$initialize invokeStatic &quot;main.clj&quot; 508]
   [clojure.main$null_opt invokeStatic &quot;main.clj&quot; 542]
   [clojure.main$null_opt invoke &quot;main.clj&quot; 539]
   [clojure.main$main invokeStatic &quot;main.clj&quot; 664]
   [clojure.main$main doInvoke &quot;main.clj&quot; 616]
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 137]
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
   [clojure.main main &quot;main.java&quot; 40]],
  :cause &quot;capacity &amp;lt; 0: (-689151616 &amp;lt; 0)&quot;,
  :phase :execution}}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/cyberdynesoftware/learnopengl/commit/6e0943c11d51a46591dbdd716f4216247aef9ba3&quot;&gt;repository&lt;/a&gt; contains the full code to reproduce the error. &lt;code&gt;read-model&lt;/code&gt; is defined in mesh-model.clj.&lt;/p&gt;
&lt;p&gt;I ran this with Clojure version 1.11.1 and Java version:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;openjdk 21.0.7 2025-04-15
OpenJDK Runtime Environment (Red_Hat-21.0.7.0.6-2) (build 21.0.7+6)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.7.0.6-2) (build 21.0.7+6, mixed mode, sharing)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There was a previous question on &lt;a rel=&quot;nofollow&quot; href=&quot;https://stackoverflow.com/questions/79689152/reading-a-3d-model-with-lwjgl-assimp-failes-in-clojure&quot;&gt;stackoverflow&lt;/a&gt; leading to this question.&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14612/method-with-parameter-called-although-provided-parameter</guid>
<pubDate>Sat, 05 Jul 2025 21:13:00 +0000</pubDate>
</item>
<item>
<title>tools.build fails with http_proxy/https_proxy set</title>
<link>https://ask.clojure.org/index.php/14602/tools-build-fails-with-httpproxy-httpsproxy-set</link>
<description>&lt;p&gt;The autopkgtest of the tools.build package fails with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Running tests in #{&quot;src/test/clojure&quot;}

Testing clojure.tools.build.tasks.test-basis
Warning: failed to load the S3TransporterFactory class
Jul 01, 2025 8:15:38 AM org.apache.http.impl.execchain.RetryExec execute
INFO: I/O exception (java.net.SocketException) caught when processing request to {s}-&amp;gt;https://repo1.maven.org:443: Network is unreachable
[...]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The autopkgtest script debian/tests/source:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#!/bin/bash

set -ueo pipefail

cp=($(&amp;lt; debian/libtools-build-clojure.classpath))
test &quot;${cp[0]}&quot; = usr/share/java/tools.build.jar
unset cp[0] # drop it

test_cp=(src/main/clojure
         src/test/clojure
         /usr/share/java/test-runner.jar
         /usr/share/java/maven-resolver-named-locks.jar
         /usr/share/java/maven-repository-metadata-3.x.jar
         &quot;${cp[@]}&quot;)

test_cp=&quot;$(IFS=:; echo &quot;${test_cp[*]}&quot;)&quot;

# Derived from ./deps.edn, and avoids a circular dep on clojure-cli
java -XX:-OmitStackTraceInFastThrow -cp &quot;$test_cp&quot; clojure.main \
     -m cognitect.test-runner cognitect.test-runner.api/test \
     --dir src/test/clojure --namespace-regex '.*'
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The Ubuntu autopkgtest infrastructure restrict the Internet access and sets http_proxy/https_proxy.&lt;/p&gt;
&lt;p&gt;Please support those proxy settings.&lt;/p&gt;
&lt;p&gt;Bug-Ubuntu: &lt;a rel=&quot;nofollow&quot; href=&quot;https://launchpad.net/bugs/2115740&quot;&gt;https://launchpad.net/bugs/2115740&lt;/a&gt;&lt;/p&gt;
</description>
<category>tools.build</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14602/tools-build-fails-with-httpproxy-httpsproxy-set</guid>
<pubDate>Wed, 02 Jul 2025 11:56:53 +0000</pubDate>
</item>
<item>
<title>Why does a qualified instance method call fails at compile time with NullPointerException if missing target</title>
<link>https://ask.clojure.org/index.php/14596/qualified-instance-compile-nullpointerexception-missing</link>
<description>&lt;p&gt;Has anyone else noticed a lot of Syntax error (NullPointerException) when using the new Class/.instanceMethod syntax? Specifically whenever I forget the first argument like &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(fn [] (String/.length))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;gets&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;#error{:cause &quot;Cannot invoke \&quot;clojure.lang.Compiler$Expr.emit(clojure.lang.Compiler$C, clojure.lang.Compiler$ObjExpr, clojure.asm.commons.GeneratorAdapter)\&quot; because \&quot;this.target\&quot; is null&quot;,
       :via [{:type clojure.lang.Compiler$CompilerException,
              :message &quot;Syntax error compiling fn* at (/private/var/folders/cr/wpw7hgnx0jj9m33g28rtbpzc0000gn/T/form-init4871175438924650637.clj:1:1).&quot;,
              :data #:clojure.error{:phase :compile-syntax-check,
                                    :line 1,
                                    :column 1,
                                    :source &quot;/private/var/folders/cr/wpw7hgnx0jj9m33g28rtbpzc0000gn/T/form-init4871175438924650637.clj&quot;,
                                    :symbol fn*},
              :at [clojure.lang.Compiler analyzeSeq &quot;Compiler.java&quot; 7677]}
             {:type java.lang.NullPointerException,
              :message &quot;Cannot invoke \&quot;clojure.lang.Compiler$Expr.emit(clojure.lang.Compiler$C, clojure.lang.Compiler$ObjExpr, clojure.asm.commons.GeneratorAdapter)\&quot; because \&quot;this.target\&quot; is null&quot;,
              :at [clojure.lang.Compiler$InstanceMethodExpr emit &quot;Compiler.java&quot; 2060]}],
       :trace [[clojure.lang.Compiler$InstanceMethodExpr emit &quot;Compiler.java&quot; 2060]
               [clojure.lang.Compiler$BodyExpr emit &quot;Compiler.java&quot; 6723]
               [clojure.lang.Compiler$FnMethod doEmit &quot;Compiler.java&quot; 6243]
               [clojure.lang.Compiler$FnMethod emit &quot;Compiler.java&quot; 6045]
               [clojure.lang.Compiler$FnExpr emitMethods &quot;Compiler.java&quot; 4500]
               [clojure.lang.Compiler$ObjExpr compile &quot;Compiler.java&quot; 5136]
               [clojure.lang.Compiler$FnExpr parse &quot;Compiler.java&quot; 4662]
               [clojure.lang.Compiler analyzeSeq &quot;Compiler.java&quot; 7667]
               [clojure.lang.Compiler analyze &quot;Compiler.java&quot; 7360]
               [clojure.lang.Compiler analyze &quot;Compiler.java&quot; 7316]
               [clojure.lang.Compiler$BodyExpr$Parser parse &quot;Compiler.java&quot; 6683]
               [clojure.lang.Compiler$FnMethod parse &quot;Compiler.java&quot; 6022]
               [clojure.lang.Compiler$FnExpr parse &quot;Compiler.java&quot; 4585]
               [clojure.lang.Compiler analyzeSeq &quot;Compiler.java&quot; 7667]
               [clojure.lang.Compiler analyze &quot;Compiler.java&quot; 7360]
               [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7736]
               [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7694]
               [clojure.core$eval invokeStatic &quot;core.clj&quot; 3232]
               [clojure.core$eval invoke &quot;core.clj&quot; 3228]
               [nrepl.middleware.interruptible_eval$evaluate$fn__966$fn__967 invoke &quot;interruptible_eval.clj&quot; 87]
               [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 152]
               [clojure.lang.AFn applyTo &quot;AFn.java&quot; 144]
               [clojure.core$apply invokeStatic &quot;core.clj&quot; 667]
               [clojure.core$with_bindings_STAR_ invokeStatic &quot;core.clj&quot; 1990]
               [clojure.core$with_bindings_STAR_ doInvoke &quot;core.clj&quot; 1990]
               [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 428]
               [nrepl.middleware.interruptible_eval$evaluate$fn__966 invoke &quot;interruptible_eval.clj&quot; 87]
               [clojure.main$repl$read_eval_print__9248$fn__9251 invoke &quot;main.clj&quot; 437]
               [clojure.main$repl$read_eval_print__9248 invoke &quot;main.clj&quot; 437]
               [clojure.main$repl$fn__9257 invoke &quot;main.clj&quot; 459]
               [clojure.main$repl invokeStatic &quot;main.clj&quot; 459]
               [clojure.main$repl doInvoke &quot;main.clj&quot; 368]
               [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 1526]
               [nrepl.middleware.interruptible_eval$evaluate invokeStatic &quot;interruptible_eval.clj&quot; 84]
               [nrepl.middleware.interruptible_eval$evaluate invoke &quot;interruptible_eval.clj&quot; 56]
               [nrepl.middleware.interruptible_eval$interruptible_eval$fn__997$fn__1001
                invoke
                &quot;interruptible_eval.clj&quot;
                152]
               [clojure.lang.AFn run &quot;AFn.java&quot; 22]
               [nrepl.middleware.session$session_exec$main_loop__1065$fn__1069 invoke &quot;session.clj&quot; 202]
               [nrepl.middleware.session$session_exec$main_loop__1065 invoke &quot;session.clj&quot; 201]
               [clojure.lang.AFn run &quot;AFn.java&quot; 22]
               [java.lang.Thread run &quot;Thread.java&quot; 1447]]}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14596/qualified-instance-compile-nullpointerexception-missing</guid>
<pubDate>Mon, 30 Jun 2025 13:33:36 +0000</pubDate>
</item>
<item>
<title>Bug in Clojurescript string/split with limit?</title>
<link>https://ask.clojure.org/index.php/14514/bug-in-clojurescript-string-split-with-limit</link>
<description>&lt;p&gt;This seems like a bug to me? Using limit in clojure.string/split (in Clojurescript) gives the wrong result on a simple split.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; NB Clojurescript
(clojure.string/split &quot;a|b&quot; #&quot;|&quot;)
;=&amp;gt; [&quot;a&quot; &quot;|&quot; &quot;b&quot;]
(clojure.string/split &quot;a|b&quot; #&quot;|&quot; 3)
;=&amp;gt; [&quot;&quot; &quot;&quot; &quot;a|b&quot;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Results should be the same?&lt;/p&gt;
&lt;p&gt;Corresponding code in Javascript&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&quot;a|b&quot;.split(/|/)
;=&amp;gt; ['a', '|', 'b']
&quot;a|b&quot;.split(/|/, 3)
;=&amp;gt; ['a', '|', 'b']
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14514/bug-in-clojurescript-string-split-with-limit</guid>
<pubDate>Wed, 23 Apr 2025 12:03:38 +0000</pubDate>
</item>
<item>
<title>Does clojure-clr work on Android?</title>
<link>https://ask.clojure.org/index.php/14512/does-clojure-clr-work-on-android</link>
<description>&lt;p&gt;&lt;strong&gt;EDIT: &lt;/strong&gt; Answer is YES. Below is my long-winded exploration.&lt;/p&gt;
&lt;p&gt;I see one of the reasons for clojure-clr-next is it will work on more platforms, is Android one of those?&lt;/p&gt;
&lt;p&gt;I'm using Termux to operate dotnet on Android.&lt;/p&gt;
&lt;p&gt;Both the clojure-clr global dotnet tool and locally compiled clojure-clr fail with exit code 1, no exceptions or anything. I tried dotnet-trace and it gets a partial trace, but no minidump. Puzzling as with the partial trace, the  documentation indicates an expectation of a minidump, maybe there is some unmet condition to emit the minidump I'm not aware of yet (env variables for it didn't work).&lt;/p&gt;
&lt;p&gt;In the trace here is an early line followed by some of the last lines:&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
&quot;system.linq!System.Linq.Enumerable.SelectManyS\ingleSelectorIterator\u003cSystem.Reflection.As\sembly,System.Type\u003e.MoveNext()&quot;&lt;/p&gt;
&lt;p&gt;[...]&lt;br&gt;
&quot;system.collections!System.Collections.Generic.\&lt;br&gt;
SortedSet\u003cSystem.Collections.Generic.KeyVa\luePair\u003cSystem.Int32,clojure.lang.CljCompi\ler.Ast.FnMethod\u003e\u003e.AddIfNotPresent(Sy\stem.Collections.Generic.KeyValuePair`2\u003cin\t,&lt;/p&gt;
&lt;p&gt;[...last line...]&lt;br&gt;
&quot;ManagedModule!System.Buffers.SharedArrayPool\u\003cSystem.Byte\u003e.Trim()&quot;&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;So maybe something to do with reflection, or that SharedArrayPool?&lt;/p&gt;
&lt;p&gt;I tried inserting some logging to Clojure.Main, but nothing logged as it appears to fail before CljMain.Main() is called. Possibly fails during setting up attributes on one of the classes, in one of the Symbol.intern() or RT.var() calls or somewhere else?&lt;/p&gt;
&lt;p&gt;Couldn't run the &lt;code&gt;dotnet msbuild build.proj -t:Test -p:TestTargetFramework=net8.0&lt;/code&gt;, fails with:&lt;br&gt;
&lt;code&gt;Clojure.Main -&amp;gt; /data/data/com.termux/files/home/dev/clojure-clr/Clojure/Clojure.Main/bin/Debug/net8.0/Clojure.Main.dll
  ClojureCompileAssets = ''
  ClojureMainAssets = ''
  ClojureTestsAssets = ''
/data/data/com.termux/files/home/dev/clojure-clr/Clojure/build.proj(177,5): error MSB3073: The command &quot;dotnet run --project /data/data/com.termux/files/home/dev/clojure-clr/Clojure/Clojure.Main --framework net8.0 -c Debug -p:TargetOS=linux-bionic -p:TargetPlatform=arm64 -p:TargetFramework=net8.0 -p:TargetFrameworks='net8.0' -- run_test.clj&quot; exited with code 1.&lt;/code&gt;&lt;br&gt;
I had to edit build.proj a bit to get custom -p:TargetFrameworks and such to pass through, but still fails with exit code 1.&lt;/p&gt;
&lt;p&gt;Well I'll continue poking around in this uncharted territory.&lt;/p&gt;
</description>
<category>ClojureCLR</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14512/does-clojure-clr-work-on-android</guid>
<pubDate>Sat, 19 Apr 2025 19:59:28 +0000</pubDate>
</item>
<item>
<title>&quot;:added&quot; metadata missing from some new public functions in namespace clojure.java.process</title>
<link>https://ask.clojure.org/index.php/14504/metadata-missing-public-functions-namespace-clojure-process</link>
<description>&lt;p&gt;These functions in the namespace clojure.java.process are mentioned in the doc string for the namespace, and have doc strings, but do not have metadata &lt;code&gt;{:added &quot;1.12&quot;}&lt;/code&gt; as do other new public docstring'ed functions in that namespace:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;stdin&lt;/li&gt;
&lt;li&gt;stdout&lt;/li&gt;
&lt;li&gt;stderr&lt;/li&gt;
&lt;li&gt;exit-ref&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I did not find any other such functions anywhere else that are new in Clojure 1.12.0 vs. Clojure 1.11.1.&lt;/p&gt;
</description>
<category>Docs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14504/metadata-missing-public-functions-namespace-clojure-process</guid>
<pubDate>Fri, 11 Apr 2025 16:29:23 +0000</pubDate>
</item>
<item>
<title>Why is shuffle not nil-safe?</title>
<link>https://ask.clojure.org/index.php/14479/why-is-shuffle-not-nil-safe</link>
<description>&lt;p&gt;Shuffling an empty collection is fine:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (shuffle [])
[]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But shuffling &lt;code&gt;nil&lt;/code&gt; results in NPE:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (shuffle nil)
Execution error (NullPointerException) at java.util.ArrayList/&amp;lt;init&amp;gt; (ArrayList.java:181).
Cannot invoke &quot;java.util.Collection.toArray()&quot; because &quot;c&quot; is null
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Why is it not nil-safe like other seq ops?&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14479/why-is-shuffle-not-nil-safe</guid>
<pubDate>Wed, 26 Mar 2025 14:04:15 +0000</pubDate>
</item>
<item>
<title>Docstring typos in clojure.core/bytes, chars, shorts</title>
<link>https://ask.clojure.org/index.php/14447/docstring-typos-in-clojure-core-bytes-chars-shorts</link>
<description>&lt;p&gt;The docstring of &lt;code&gt;clojure.core/bytes&lt;/code&gt; has a minor typo:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;  &quot;Casts to bytes[]&quot;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;which should read &lt;code&gt;byte[]&lt;/code&gt;; similarly for the docstrings of &lt;code&gt;chars&lt;/code&gt; and &lt;code&gt;shorts&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;Given the new array class syntax in Clojure 1.12 perhaps these should be updated to read &lt;code&gt;byte/1&lt;/code&gt;,  &lt;code&gt;float/1&lt;/code&gt; etc. instead of using Java style syntax? &lt;/p&gt;
</description>
<category>Docs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14447/docstring-typos-in-clojure-core-bytes-chars-shorts</guid>
<pubDate>Thu, 06 Mar 2025 06:54:53 +0000</pubDate>
</item>
<item>
<title>Source maps show the wrong row in ClojureScript</title>
<link>https://ask.clojure.org/index.php/14441/source-maps-show-the-wrong-row-in-clojurescript</link>
<description>&lt;p&gt;When some error occurs in ClojureScript, the source map usually shows the line above the actual error, but sometimes it's even worse. An example is on my own plug-in Lazuli, where using Reagent with the newer React causes a very weird source map, as following GIF:&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://i.imgur.com/kbruZy6.gif&quot; alt=&quot;GIF with the stacktrace&quot;&gt;&lt;/p&gt;
&lt;p&gt;The stracktrace shows:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;lazuli$connections$conn_view            @ connections.cljs:64
(anonymous)	                            @ connections.cljs:199
lazuli$connections$connect_nrepl_BANG_  @	connections.cljs:195
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But the &lt;em&gt;correct lines&lt;/em&gt; are 63, and 197, with 195 being probably the only correct line in this &lt;/p&gt;
&lt;p&gt;Is there any way to configure this to be correct?&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14441/source-maps-show-the-wrong-row-in-clojurescript</guid>
<pubDate>Wed, 05 Mar 2025 02:52:12 +0000</pubDate>
</item>
<item>
<title>clojure.tools.reader.edn/read can cause incorrect column number for token at end of input</title>
<link>https://ask.clojure.org/index.php/14437/clojure-tools-reader-cause-incorrect-column-number-token-input</link>
<description>&lt;p&gt;&lt;strong&gt;Context&lt;/strong&gt;&lt;br&gt;
A user reported that &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clj-commons/rewrite-clj/issues/367&quot;&gt;rewrite-clj column number metadata can be incorrect for a token at the end of input&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Rewrite-clj uses clojure.tools/reader to read clojure source.&lt;br&gt;
It uses &lt;code&gt;clojure.tools.reader.reader-types/get-column-number&lt;/code&gt; to discover the current column offset.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Affected&lt;/strong&gt;&lt;br&gt;
clojure.tools/reader v1.3.4 through v1.5.0&lt;br&gt;
Clojure only (not ClojureScript)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Env&lt;/strong&gt;&lt;br&gt;
On Linux using Clojure CLI 1.12.0.1517 with JDK 23.0.2 (temurin)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Symptom&lt;/strong&gt;&lt;br&gt;
When the element at end of input is a token, after it is read, the column number is one less than it should be.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Setup&lt;/strong&gt;&lt;br&gt;
Let's setup a playground in &lt;code&gt;foo.clj&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns foo
  (:require [clojure.pprint :refer [pprint]]
            [clojure.tools.reader.edn :as edn]
            [clojure.tools.reader.reader-types :as rt]))

(defn reader [s]
  (-&amp;gt; s
      rt/string-push-back-reader
      rt/indexing-push-back-reader))

(defn dump-with-cols [s]
  (println &quot;input string:&quot; s)
  (println &quot;colnums:     &quot; (apply str (take (inc (count s)) (cycle [1 2 3 4 5 6 7 8 9 0])))))

(defn read-by-obj [s]
  (with-open [r (reader s)]
    (loop [acc [{:at :bof :col-number (rt/get-column-number r)}]
           obj (edn/read r false ::eof {})]
      (if (not= ::eof obj)
        (recur (conj acc {:after obj :col-number (rt/get-column-number r)})
               (edn/read r false ::eof {}))
        (conj acc {:at :eof :col-number (rt/get-column-number r)})))))

(let [s (first *command-line-args*)]
  (dump-with-cols s)
  (println &quot;parse result:&quot;)
  (pprint (read-by-obj s)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Reproduction&lt;/strong&gt;&lt;br&gt;
Using clojure.tools/reader v1.5.0:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Sdeps '{:deps {org.clojure/tools.reader {:mvn/version &quot;1.5.0&quot;}}}' \
        -M foo.clj ':bip :bop'
input string: :bip :bop
colnums:      1234567890
parse result:
[{:at :bof, :col-number 1}
 {:after :bip, :col-number 5}
 {:after :bop, :col-number 9}
 {:at :eof, :col-number 9}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Notice after &lt;code&gt;:bip&lt;/code&gt; we see the correct &lt;code&gt;:col-number 5&lt;/code&gt;, but after &lt;code&gt;:bop&lt;/code&gt; we see the incorrect &lt;code&gt;:col-number 9&lt;/code&gt;; it should be &lt;code&gt;:col-number 10&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;An incorrect column number occurs for any unwrapped last token, a number:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Sdeps '{:deps {org.clojure/tools.reader {:mvn/version &quot;1.5.0&quot;}}}' \
        -M foo.clj 123
input string: 123
colnums:      1234
parse result:
[{:at :bof, :col-number 1}
 {:after 123, :col-number 3}
 {:at :eof, :col-number 3}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;a symbol:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Sdeps '{:deps {org.clojure/tools.reader {:mvn/version &quot;1.5.0&quot;}}}' \
        -M foo.clj x
input string: x
colnums:      12
parse result:
[{:at :bof, :col-number 1}
 {:after x, :col-number 1}
 {:at :eof, :col-number 1}]

&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But we get a correct result for syntax wrapped elements:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Sdeps '{:deps {org.clojure/tools.reader {:mvn/version &quot;1.5.0&quot;}}}' \
        -M foo.clj '(x)'
input string: (x)
colnums:      1234
parse result:
[{:at :bof, :col-number 1}
 {:after (x), :col-number 4}
 {:at :eof, :col-number 4}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;strong&gt;Diagnosis&lt;/strong&gt;&lt;br&gt;
If I dial clojure.tools/reader back to v1.3.3, I don't see the issue:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Sdeps '{:deps {org.clojure/tools.reader {:mvn/version &quot;1.3.3&quot;}}}' \
        -M foo.clj ':bip :bop'
input string: :bip :bop
colnums:      1234567890
parse result:
[{:at :bof, :col-number 1}
 {:after :bip, :col-number 5}
 {:after :bop, :col-number 10}
 {:at :eof, :col-number 10}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then bump one version to v1.3.4, I see the issue:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Sdeps '{:deps {org.clojure/tools.reader {:mvn/version &quot;1.3.4&quot;}}}' \
        -M foo.clj ':bip :bop'
input string: :bip :bop
colnums:      1234567890
parse result:
[{:at :bof, :col-number 1}
 {:after :bip, :col-number 5}
 {:after :bop, :col-number 9}
 {:at :eof, :col-number 9}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;There was &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/tools.reader/commit/c8981dd6ac7a560db85321b03278d03caf2aed39&quot;&gt;only one significant change between v1.3.3 and v1.3.4&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Unreading the character at eof is causing the off-by-one issue.&lt;/p&gt;
&lt;p&gt;If I change the &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/tools.reader/blob/30d9f1d04417adc222ab57178dfd56d5d7a01d58/src/main/clojure/clojure/tools/reader/edn.clj#L54-L63&quot;&gt;existing&lt;/a&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  (loop [sb (StringBuilder.)
         ch initch]
    (if (or (whitespace? ch)
            (macro-terminating? ch)
            (nil? ch))
      (do (unread rdr ch)
          (str sb))
      (if (not-constituent? ch)
        (err/throw-bad-char rdr kind ch)
        (recur (doto sb (.append ch)) (read-char rdr))))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;To:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  (loop [sb (StringBuilder.)
         ch initch]
    (cond
      (or (whitespace? ch)
          (macro-terminating? ch))
      (do (unread rdr ch)
          (str sb))

      (nil? ch)
      (str sb)

      (not-constituent? ch)
      (err/throw-bad-char rdr kind ch)

      :else
      (recur (doto sb (.append ch)) (read-char rdr)))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The problem is resolved for me.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Next Steps&lt;/strong&gt;&lt;br&gt;
Happy to contribute a patch if the above makes sense to you and you think it is worthwhile to fix.&lt;/p&gt;
</description>
<category>tools.reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14437/clojure-tools-reader-cause-incorrect-column-number-token-input</guid>
<pubDate>Sat, 01 Mar 2025 16:58:43 +0000</pubDate>
</item>
<item>
<title>Breaking change in 1.12.0 - a static field is always preferred to a static function with the same name</title>
<link>https://ask.clojure.org/index.php/14435/breaking-change-static-field-always-preferred-static-function</link>
<description>&lt;p&gt;In 1.11.4, if a class has a static field and a static method with the same name, attempting to use the method as a function works as expected.&lt;/p&gt;
&lt;p&gt;In 1.12.0, the static field is always returned instead.&lt;/p&gt;
&lt;p&gt;A CLI reproduction case:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.0
user=&amp;gt; (add-lib 'com.badlogicgames.gdx/gdx)
[com.badlogicgames.gdx/gdx com.badlogicgames.gdx/gdx-jnigen-loader]
user=&amp;gt; (import '(com.badlogic.gdx.math MathUtils))
com.badlogic.gdx.math.MathUtils
user=&amp;gt; MathUtils/random
#object[com.badlogic.gdx.math.RandomXS128 0x3df978b9 &quot;com.badlogic.gdx.math.RandomXS128@3df978b9&quot;]
user=&amp;gt; (MathUtils/random)
#object[com.badlogic.gdx.math.RandomXS128 0x3df978b9 &quot;com.badlogic.gdx.math.RandomXS128@3df978b9&quot;]
user=&amp;gt; (MathUtils/random 0 10)
#object[com.badlogic.gdx.math.RandomXS128 0x3df978b9 &quot;com.badlogic.gdx.math.RandomXS128@3df978b9&quot;]


Clojure 1.11.4
user=&amp;gt; (import '(com.badlogic.gdx.math MathUtils))
com.badlogic.gdx.math.MathUtils
user=&amp;gt; MathUtils/random
#object[com.badlogic.gdx.math.RandomXS128 0x71c905a3 &quot;com.badlogic.gdx.math.RandomXS128@71c905a3&quot;]
user=&amp;gt; (MathUtils/random)
0.37632704
user=&amp;gt; (MathUtils/random 0 10)
0
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A potential test case:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;diff --git a/test/clojure/test_clojure/java_interop.clj b/test/clojure/test_clojure/java_interop.clj
index 4a503884..c99370a3 100644
--- a/test/clojure/test_clojure/java_interop.clj
+++ b/test/clojure/test_clojure/java_interop.clj
@@ -20,7 +20,7 @@
             [clojure.test-helper :refer [should-not-reflect]])
   (:import java.util.Base64
            (java.io File FileFilter FilenameFilter)
-           (java.util UUID)
+           (java.util ArrayList Collections$UnmodifiableCollection UUID)
            (java.util.concurrent.atomic AtomicLong AtomicInteger)
            (clojure.test FIConstructor FIStatic FunctionalTester AdapterExerciser)))
 
@@ -783,6 +783,16 @@
   (def fi-static (FIStatic/numbers (fn [i] (&amp;lt; i 0))))
   (is (= [-2 -1] fi-static)))
 
+(deftest static-field-and-method
+  (let [fv FIStatic/numbers
+        mv0 (FIStatic/numbers)
+        mv1 (FIStatic/numbers neg?)]
+    (is (= [-2 -1 0 1 2] fv))
+    (is (instance? Collections$UnmodifiableCollection fv))
+    (is (= [-2 -1 0 1 2] mv0))
+    (is (instance? ArrayList mv0))
+    (is (= [-2 -1] mv1))))
+
 ;; newDirectoryStream is overloaded, takes ^[Path String] or ^[Path DirectoryStream$Filter]
 ;; so this method will reflect
 (defn get-dir-stream [^java.nio.file.Path dir-path glob-pattern]
diff --git a/test/java/clojure/test/FIStatic.java b/test/java/clojure/test/FIStatic.java
index 8273c357..4a8198ae 100644
--- a/test/java/clojure/test/FIStatic.java
+++ b/test/java/clojure/test/FIStatic.java
@@ -1,13 +1,20 @@
 package clojure.test;
 
+import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.function.Predicate;
 
 public class FIStatic {
 
+    public static List&amp;lt;Integer&amp;gt; numbers = Collections.unmodifiableList(Arrays.asList(-2, -1, 0, 1, 2));
+
+    public static List&amp;lt;Object&amp;gt; numbers () {
+        return new ArrayList&amp;lt;&amp;gt;(numbers);
+    }
+
     public static List&amp;lt;Object&amp;gt; numbers(Predicate&amp;lt;Integer&amp;gt; pred) {
-        List&amp;lt;Integer&amp;gt; numbers = Arrays.asList(-2, -1, 0, 1, 2);
         Object[] filteredNumbers =  numbers.stream().filter(pred).toArray();
         return Arrays.asList(filteredNumbers);
     }
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14435/breaking-change-static-field-always-preferred-static-function</guid>
<pubDate>Fri, 28 Feb 2025 20:06:59 +0000</pubDate>
</item>
<item>
<title>`doseq` and `for` expands body twice</title>
<link>https://ask.clojure.org/index.php/14433/doseq-and-for-expands-body-twice</link>
<description>&lt;p&gt;The bodies of &lt;code&gt;doseq&lt;/code&gt; and &lt;code&gt;for&lt;/code&gt; seem to be duplicated in their expansions.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure
user=&amp;gt; (defmacro a [] (prn :expand))
#'user/a
user=&amp;gt; (doseq [_ nil] (a))
:expand
:expand
nil
user=&amp;gt; (for [_ nil] (a))
:expand
:expand
()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I found the same problem in ClojureScript. I could not find an existing discussion about this so I'm not sure if this is by design, apologies if so. I'm aware that these macros have a large code footprint and that &lt;code&gt;doseq&lt;/code&gt; cannot use closures (the usual way to prevent exponential expansion), but I missed this detail.&lt;/p&gt;
&lt;p&gt;This leads to exponential code blowup if these forms are nested. Artificial demonstration:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure
Clojure 1.12.0
user=&amp;gt; (def counter (atom -1))
#'user/counter
user=&amp;gt; (defmacro a [] (prn :expand (swap! counter inc)))
#'user/a
user=&amp;gt; #(doseq [_ 1] (doseq [_ 2] (doseq [_ 3] (doseq [_ 4] (a)))))
:expand 0
:expand 1
:expand 2
:expand 3
:expand 4
:expand 5
:expand 6
:expand 7
:expand 8
:expand 9
:expand 10
:expand 11
:expand 12
:expand 13
:expand 14
:expand 15
#object[user$eval926$fn__927 0x76563d26 &quot;user$eval926$fn__927@76563d26&quot;]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This might be especially relevant to core.async, where placing &lt;code&gt;go&lt;/code&gt; under &lt;code&gt;doseq&lt;/code&gt; is idiomatic, since &lt;code&gt;go&lt;/code&gt; is expensive in both expansion time and code size.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (time (eval '(doseq [_ nil] (a/go (doseq [_ nil] (a/go (doseq [_ nil] (a/go))))))))
&quot;Elapsed time: 837.230917 msecs&quot;
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It also leads to duplicated reflection warnings from the fully expanded forms, which is how I found this problem.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (doseq [_ nil] (Thread/sleep (identity 1)))
Reflection warning, NO_SOURCE_PATH:1:16 - call to static method sleep on java.lang.Thread can't be resolved (argument types: unknown).
Reflection warning, NO_SOURCE_PATH:1:16 - call to static method sleep on java.lang.Thread can't be resolved (argument types: unknown).
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I believe the exponential expansion for &lt;code&gt;doseq&lt;/code&gt; was introduced in Clojure 1.1.0 with support for chunked seqs with &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/commit/1abb7a56de1678321054af7fce183184f06974dd&quot;&gt;this commit&lt;/a&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clojure -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.0.0&quot;}}}' 
Downloading: org/clojure/clojure/1.0.0/clojure-1.0.0.pom from central
Downloading: org/clojure/clojure/1.0.0/clojure-1.0.0.jar from central
Clojure 1.0.0-
user=&amp;gt; (defmacro a [] (prn :expand))
#'user/a
user=&amp;gt; (doseq [_ nil] (a))
:expand
nil
user=&amp;gt; ^D
$ clojure -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.1.0&quot;}}}'
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.pom from central
Downloading: org/clojure/clojure/1.1.0/clojure-1.1.0.jar from central
Clojure 1.1.0
user=&amp;gt; (defmacro a [] (prn :expand))
#'user/a
user=&amp;gt; (doseq [_ nil] (a))
:expand
:expand
nil
user=&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At first I wasn't sure if this was hopeless, but I think &lt;code&gt;doseq&lt;/code&gt; is fixable fusing the chunked and non-chunked cases like so:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defmacro doseq
  &quot;Repeatedly executes body (presumably for side-effects) with
  bindings and filtering as provided by \&quot;for\&quot;.  Does not retain
  the head of the sequence. Returns nil.
  
  Unlike clojure.core/doseq, does not cause exponential macro expansion
  of expressions in bindings or body.&quot;
  [seq-exprs &amp;amp; body]
  (#'clojure.core/assert-args
     (vector? seq-exprs) &quot;a vector for its binding&quot;
     (even? (count seq-exprs)) &quot;an even number of forms in binding vector&quot;)
  (let [step (fn step [recform exprs]
               (if-not exprs
                 [true `(do ~@body)]
                 (let [k (first exprs)
                       v (second exprs)]
                   (if (keyword? k)
                     (let [steppair (step recform (nnext exprs))
                           needrec (steppair 0)
                           subform (steppair 1)]
                       (cond
                         (= k :let) [needrec `(let ~v ~subform)]
                         (= k :while) [false `(when ~v
                                                ~subform
                                                ~@(when needrec [recform]))]
                         (= k :when) [false `(if ~v
                                               (do
                                                 ~subform
                                                 ~@(when needrec [recform]))
                                               ~recform)]))
                     (let [seq- (gensym &quot;seq_&quot;)
                           chunk- (with-meta (gensym &quot;chunk_&quot;)
                                             {:tag 'clojure.lang.IChunk})
                           count- (gensym &quot;count_&quot;)
                           i- (gensym &quot;i_&quot;)
                           in-chunk- (gensym &quot;in-chunk_&quot;)
                           recform `(if ~in-chunk-
                                      (recur ~seq- ~chunk- ~count- (unchecked-inc ~i-))
                                      (recur (next ~seq-) nil 0 0))
                           steppair (step recform (nnext exprs))
                           needrec (steppair 0)
                           subform (steppair 1)]
                       [true
                        `(loop [~seq- (seq ~v), ~chunk- nil,
                                ~count- 0, ~i- 0]
                           (let [~in-chunk- (&amp;lt; ~i- ~count-)
                                 ~seq- (if ~in-chunk- ~seq- (seq ~seq-))]
                             (when (if ~in-chunk- true ~seq-)
                               (let [chunked?# (if ~in-chunk- false (chunked-seq? ~seq-))
                                     ~k (if ~in-chunk-
                                          (.nth ~chunk- ~i-)
                                          (if chunked?# nil (first ~seq-)))]
                                 (if (if ~in-chunk- false chunked?#)
                                   (let [c# (chunk-first ~seq-)]
                                     (recur (chunk-rest ~seq-) c#
                                            (int (count c#)) (int 0)))
                                   (do ~subform
                                       ~@(when needrec [recform])))))))])))))]
    (nth (step nil (seq seq-exprs)) 1)))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Macros</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14433/doseq-and-for-expands-body-twice</guid>
<pubDate>Wed, 26 Feb 2025 23:15:06 +0000</pubDate>
</item>
<item>
<title>Clojure 1.12 breaks Serialization for records implementing IFn</title>
<link>https://ask.clojure.org/index.php/14410/clojure-breaks-serialization-for-records-implementing-ifn</link>
<description>&lt;p&gt;If you have a class/record that implements a functional interface AND &lt;code&gt;IFn&lt;/code&gt;, serializing it will throw the same error as CLJ-2880. Here's a repro&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [^java.util.function.Function my-f
      (reify
        Serializable
        java.util.function.Function
        clojure.lang.IFn
        )]
  (with-open [os (java.io.ObjectOutputStream. (java.io.ByteArrayOutputStream.))]
    (.writeObject os my-f)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Will throw &lt;code&gt;java.io.NotSerializableException&lt;/code&gt;. If you comment out &lt;code&gt;clojure.lang.IFn&lt;/code&gt;, this code works.&lt;/p&gt;
&lt;p&gt;This is a regression from 1.11.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14410/clojure-breaks-serialization-for-records-implementing-ifn</guid>
<pubDate>Fri, 21 Feb 2025 20:51:39 +0000</pubDate>
</item>
<item>
<title>Auto-descending in clojure.data.zip doesn't seem to make a difference</title>
<link>https://ask.clojure.org/index.php/14380/auto-descending-clojure-data-zip-doesnt-seem-make-difference</link>
<description>&lt;p&gt;Learning about zippers, I am trying to make sense of the difference between &lt;code&gt;children&lt;/code&gt; and &lt;code&gt;children-auto&lt;/code&gt;, as documented in the &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.github.io/data.zip/&quot;&gt;auto-generated docs&lt;/a&gt;, however, by reviewing the code and inspecting its history with git-log, it looks like the last reading of this meta property (possibly through the &lt;code&gt;auto?&lt;/code&gt; function) was removed by &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/data.zip/commit/c5d6ca25c128f9fe937b11505c7c9736cfa2dd9a&quot;&gt;this commit in 2016&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I think I will give up my trying to understand what &quot;auto-descending by &lt;code&gt;tag=&lt;/code&gt;&quot; meant when it no longer matters. I would find it good to remove mentions of it from the documentation to save time to future learners like me, or at least clarify that the behaviour of &lt;code&gt;tag=&lt;/code&gt; doesn't change with the choice of &lt;code&gt;children&lt;/code&gt; v. &lt;code&gt;children-auto&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;What &lt;em&gt;could&lt;/em&gt; change, anyway, if there is no code sensitive to this metadatum in the library? Is there another library that uses it, or is it targeted only at user code (remembered in a comment to the &lt;code&gt;auto&lt;/code&gt; function), or is it just not useful anymore and should the metadatum (the &lt;code&gt;:zip-filter/no-auto?&lt;/code&gt; key) be dropped and associated functions (including &lt;code&gt;children-auto&lt;/code&gt;) with it?&lt;/p&gt;
</description>
<category>data.zip</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14380/auto-descending-clojure-data-zip-doesnt-seem-make-difference</guid>
<pubDate>Mon, 10 Feb 2025 11:05:44 +0000</pubDate>
</item>
<item>
<title>clojure.java.data/from-java throws stack overflow</title>
<link>https://ask.clojure.org/index.php/14379/clojure-java-data-from-java-throws-stack-overflow</link>
<description>&lt;p&gt;I use the following function to get scrollpoints from a  client io.qdrant.client.QdrantClient&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def client ...) =&amp;gt; io.qdrant.client.QdrantClient

(defn make-scroll-points [collection-name k v]
  (builder/to-java Points$ScrollPoints
                   Points$ScrollPoints$Builder
                   (Points$ScrollPoints/newBuilder)
                   {:collectionName collection-name
                    :filter (builder/to-java Points$Filter
                                             Points$Filter$Builder
                                             (Points$Filter/newBuilder)
                                             {:addMust (ConditionFactory/matchKeyword (name k) (str v))}
                                             {})
                    :limit 1
                    :withPayload (WithPayloadSelectorFactory/enable true)}
                   {}))

(def scroll-points (qdrant/make-scroll-points  &amp;lt;collection-name&amp;gt; :user &quot;user-1&quot;))

(def scrolled (.get (.scrollAsync client scroll-points)))
&lt;/code&gt;&lt;/pre&gt;
&lt;pre&gt;&lt;code&gt;(bean scrolled)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;works,  but when i do&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(clojure.java.data/from-java scrolled)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I get a stackoverflow error&lt;/p&gt;
</description>
<category>java.data</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14379/clojure-java-data-from-java-throws-stack-overflow</guid>
<pubDate>Mon, 10 Feb 2025 10:39:57 +0000</pubDate>
</item>
<item>
<title>When using remote prepl server, *repl* is false, preventing use of add-lib and related functions</title>
<link>https://ask.clojure.org/index.php/14374/using-remote-prepl-server-false-preventing-related-functions</link>
<description>&lt;p&gt;To reproduce:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clojure -J-Dclojure.server.jvm=&quot;{:port 5555 :accept clojure.core.server/io-prepl}&quot;

Clojure 1.12.0
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;then&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;nc localhost 5555
*repl*
{:tag :ret, :val &quot;false&quot;, :ns &quot;user&quot;, :ms 0, :form &quot;*repl*&quot;}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>REPL</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14374/using-remote-prepl-server-false-preventing-related-functions</guid>
<pubDate>Thu, 06 Feb 2025 13:54:48 +0000</pubDate>
</item>
<item>
<title>SourceDataLine method not found</title>
<link>https://ask.clojure.org/index.php/14351/sourcedataline-method-not-found</link>
<description>&lt;p&gt;Hi, I've found some weird behaviour when attempting to play a sound using a &lt;code&gt;javax.sound.sampled.SourceDataLine&lt;/code&gt;. The following code illustrates the problem:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns cljtest.core)
(import '[java.util Random]
        '[javax.sound.sampled AudioSystem AudioFormat])

; create an AudioFormat instance:
(def fmt (AudioFormat. 44100. 16 2 true false))

; create some data representing a second of white noise:
(def data (byte-array 176400))
(.nextBytes (Random.) data)

; define a function that creates a SourceDataLine and uses it to play a sound:
(defn play1 []
  (let [l (AudioSystem/getSourceDataLine fmt)]
    (.open l) (.start l) (.write l data 0 (count data))))

; define a function that creates a SourceDataLine and returns it:
(defn getline []
  (AudioSystem/getSourceDataLine fmt))

; define a function that uses the output of getline to play a sound:
(defn play2 []
  (let [l (getline)]
    (.open l) (.start l) (.write l data 0 (count data))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Compiling this with Clojure 1.12.0 using Leiningen, &lt;code&gt;play1&lt;/code&gt; does what it's supposed to, but &lt;code&gt;play2&lt;/code&gt; gives me the following error:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Execution error (IllegalArgumentException) at cljtest.core/play2 (core.clj:24).
No matching method write found taking 3 args for class com.sun.media.sound.DirectAudioDevice$DirectSDL
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I get this error using both OpenJDK 21.0.5.11-hotspot and Oracle's JDK 23. Also with Clojure 1.11.0 and 1.10.0, but 1.9.0 works fine. Anyone know why this is happening?&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14351/sourcedataline-method-not-found</guid>
<pubDate>Wed, 22 Jan 2025 21:38:08 +0000</pubDate>
</item>
<item>
<title>clojure.java.data.builder fails with overloaded setter</title>
<link>https://ask.clojure.org/index.php/14349/clojure-java-data-builder-fails-with-overloaded-setter</link>
<description>&lt;p&gt;Trying to run make-chat-model&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns problem.problem
  (:require [clojure.java.data.builder :as builder])
  (:import (dev.langchain4j.model.openai OpenAiChatModel)
           (dev.langchain4j.model.openai OpenAiChatModel$OpenAiChatModelBuilder)))

(defn make-chat-model []
  (builder/to-java
    OpenAiChatModel 
    OpenAiChatModel$OpenAiChatModelBuilder
    (OpenAiChatModel/builder)
    {:baseUrl  &quot;localhost&quot;
     :apiKey (System/getenv &quot;OPENAI_API_KEY&quot;)} {}))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;fails with the following error &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;:#error {}
 :cause Duplicate setter found for :modelName in dev.langchain4j.model.openai.OpenAiChatModel$OpenAiChatModelBuilder class
 :via
 [{:type java.lang.IllegalArgumentException
   :message Duplicate setter found for :modelName in dev.langchain4j.model.openai.OpenAiChatModel$OpenAiChatModelBuilder class
   :at [clojure.java.data.builder$find_setters$fn__9041 invoke builder.clj 66]}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The code is in the following repo: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/gavlooth/problem&quot;&gt;https://github.com/gavlooth/problem&lt;/a&gt;&lt;/p&gt;
</description>
<category>java.data</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14349/clojure-java-data-builder-fails-with-overloaded-setter</guid>
<pubDate>Wed, 22 Jan 2025 20:27:39 +0000</pubDate>
</item>
<item>
<title>Incorrect result when evaluating `not=` on `##NaNs`</title>
<link>https://ask.clojure.org/index.php/14298/incorrect-result-when-evaluating-not-on-nans</link>
<description>&lt;p&gt;Alex Miller asked me to write this up here. I found a bug in clojure.core yesterday that involves &lt;code&gt;not=&lt;/code&gt; when used to compare NaNs. This was reported on Slack and the discussion is here:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1KBA2/p1733612992809069&quot;&gt;https://clojurians.slack.com/archives/C03S1KBA2/p1733612992809069&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Here is a more highly summarized version of the discussion from Slack (at least from my perspective). If we fire up the Clojure CLI, we can evaluate the following.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; Clojure 1.12.0
 user=&amp;gt; (= ##NaN ##NaN)
 false
 user=&amp;gt; (not= ##NaN ##NaN)
 false
 user=&amp;gt; (not (= ##NaN ##NaN))
 true
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The problem here is that &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;not&lt;/code&gt;, and &lt;code&gt;not=&lt;/code&gt; have a relationship between them. Specifically, for any &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;, if &lt;code&gt;(= x y)&lt;/code&gt; returns a boolean, then &lt;code&gt;(not (= x y))&lt;/code&gt; should return the opposite boolean, and since &lt;code&gt;not=&lt;/code&gt; is defined as &lt;code&gt;(not (= x y))&lt;/code&gt;, it should return the same value as &lt;code&gt;(not (= x y))&lt;/code&gt; for all &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt;. This doesn't happen if &lt;code&gt;x&lt;/code&gt; and &lt;code&gt;y&lt;/code&gt; are both &lt;code&gt;##NaN&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Note that there were a lot of calories burned on Slack with suggestions that doubles should never be compared for equality, that NaNs are shifty, not-quite-value objects and should be avoided, that anybody who wants to test for the presence of a NaN should use &lt;code&gt;NaN?&lt;/code&gt; which is already in clojure.core, and that the documentation around equality should be updated to say some of those things. Many of those statements are true or good practice. But all of them miss the broader point.&lt;/p&gt;
&lt;p&gt;This bug has nothing to do specifically to do with NaNs. It just seems that NaNs expose the bug. The real issue is with the contractual relationship between &lt;code&gt;=&lt;/code&gt;, &lt;code&gt;not&lt;/code&gt;, and &lt;code&gt;not=&lt;/code&gt; which appears to be violated in the presence of NaNs. Specifically, &lt;code&gt;not=&lt;/code&gt; is no longer referentially transparent with respect to &lt;code&gt;(not (= ...))&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;On Slack, @potetm decompiled the code generated for these cases and found the following.&lt;/p&gt;
&lt;p&gt;For &lt;code&gt;(not= ##NaN ##NaN)&lt;/code&gt; :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(clj-java-decompiler.core/decompile
  (not= ##NaN ##NaN))

// Decompiling class: cjd__init
import clojure.lang.*;

public class cjd__init
{
    public static final Var __not_EQ_;
    public static final Object const__1;
    
    public static void load() {
        ((IFn)cjd__init.__not_EQ_.getRawRoot()).invoke(cjd__init.const__1, cjd__init.const__1);
    }
    
    public static void __init0() {
        __not_EQ_ = RT.var(&quot;clojure.core&quot;, &quot;not=&quot;);
        const__1 = Double.NaN;
    }
    
    static {
        __init0();
        Compiler.pushNSandLoader(RT.classForName(&quot;cjd__init&quot;).getClassLoader());
        try {
            load();
            Var.popThreadBindings();
        }
        finally {
            Var.popThreadBindings();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And then for &lt;code&gt;(not (= ##NaN ##NaN))&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(clj-java-decompiler.core/decompile
  (not (= ##NaN ##NaN)))

// Decompiling class: cjd__init
import clojure.lang.*;

public class cjd__init
{
    public static final Var __not;
    
    public static void load() {
        ((IFn)cjd__init.__not.getRawRoot()).invoke(Util.equiv(Double.NaN, Double.NaN) ? Boolean.TRUE : Boolean.FALSE);
    }
    
    public static void __init0() {
        __not = RT.var(&quot;clojure.core&quot;, &quot;not&quot;);
    }
    
    static {
        __init0();
        Compiler.pushNSandLoader(RT.classForName(&quot;cjd__init&quot;).getClassLoader());
        try {
            load();
            Var.popThreadBindings();
        }
        finally {
            Var.popThreadBindings();
        }
    }
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It appears that the compiler optimizes the call to &lt;code&gt;=&lt;/code&gt; and does not box the &lt;code&gt;##NaN&lt;/code&gt; values when compiling &lt;code&gt;(not (= ##NaN ##NaN))&lt;/code&gt;, whereas the call to &lt;code&gt;not=&lt;/code&gt; receives the &lt;code&gt;##NaN&lt;/code&gt;s boxed as Doubles. This then causes a subsequent call to &lt;code&gt;clojure.lang.Util/equiv&lt;/code&gt; (after following the call chain through &lt;code&gt;not=&lt;/code&gt; -&amp;gt; &lt;code&gt;=&lt;/code&gt; -&amp;gt; &lt;code&gt;clojure.lang.Util/equiv&lt;/code&gt;) to return &lt;code&gt;true&lt;/code&gt; improperly (since NaNs are never equal to anything, even themselves).&lt;/p&gt;
&lt;p&gt;IMO, this is a bug, albeit a low priority one. Most programmers successfully use floating point math without ever having to deal with NaNs. While NaNs seem to trigger the bug, there may be other cases that also trigger it. I can't speak to that.&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14298/incorrect-result-when-evaluating-not-on-nans</guid>
<pubDate>Sun, 08 Dec 2024 21:14:02 +0000</pubDate>
</item>
<item>
<title>Incorrect stream reads in clojure.java.io</title>
<link>https://ask.clojure.org/index.php/14256/incorrect-stream-reads-in-clojure-java-io</link>
<description>&lt;p&gt;I've noticed that the &lt;code&gt;clojure.java.io&lt;/code&gt; namespace's code includes a very common mistake when reading InputStreams. Your typical &lt;code&gt;do-copy&lt;/code&gt; will have some variation of this loop:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(let [buffer (make-array Byte/TYPE (buffer-size opts))]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(loop []
  (let [size (.read input buffer)]
    (when (pos? size)
      (do (.write output buffer 0 size)
          (recur))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;It is incorrect to say &lt;code&gt;when (pos? size)&lt;/code&gt; because the InputStream interface has this definition for read method return:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;Returns:
the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Yes, it is perfectly legal for &lt;code&gt;read&lt;/code&gt; to return 0 bytes read when the stream is not at the end yet. &lt;/p&gt;
&lt;p&gt;I guess they made it like that so that you can return 0 bytes from a socket that is stalled and enable the caller to timeout or abort or do something else.&lt;/p&gt;
&lt;p&gt;In any case the correct condition for detecting end of stream is to compare the return to &lt;code&gt;-1&lt;/code&gt;.&lt;/p&gt;
</description>
<category>IO</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14256/incorrect-stream-reads-in-clojure-java-io</guid>
<pubDate>Mon, 18 Nov 2024 14:34:28 +0000</pubDate>
</item>
<item>
<title>Java interop issue</title>
<link>https://ask.clojure.org/index.php/14240/java-interop-issue</link>
<description>&lt;p&gt;Hi everyone,&lt;/p&gt;
&lt;p&gt;Failing to make clojure work with our commercial java library. I can run the following Java code on my machine and it works fine: &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;import com.numerix.pro.Application;
import com.numerix.pro.ApplicationCall;
import com.numerix.pro.ApplicationData;
import com.numerix.pro.ApplicationObjectFactory;
import com.numerix.pro.ApplicationWarning;

public final class FxAmericanOption {

    public static void main(final String argv[]) 
    {
        int rVal = 0;      // exit value
        try {
            System.out.println(&quot;Running: &quot; + new Throwable().getStackTrace()[0].getClassName() + &quot;\n&quot;);

            final Application app = new Application();
            {
                final ApplicationCall call = new ApplicationCall();
                call.addValue(&quot;ID&quot;,       &quot;USD_Curve&quot;);
                call.addValue(&quot;OBJECT&quot;,   &quot;Curve&quot;);
                call.addValue(&quot;TYPE&quot;,     &quot;Yield&quot;);
                call.addValue(&quot;Now Date&quot;, ApplicationObjectFactory.parseDate(&quot;26-Oct-2003&quot;));
                call.addValue(&quot;CURRENCY&quot;, &quot;USD&quot;);
                call.addValue(&quot;RATE&quot;,     0.04);

                final String[] outHeaders =
                    new String[] {&quot;Updated&quot;, &quot;Timer&quot;, &quot;ID&quot;};

                final ApplicationWarning warning = new ApplicationWarning();

                app.call(call, outHeaders, warning);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I tried porting it to clojure 1.12 like this &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns hello
  (:import (com.numerix.pro Application ApplicationCall
                            ApplicationWarning 
                            ApplicationObjectFactory)))
           
(def myapp (new Application))
(def appcall (new ApplicationCall))
(def warning (new ApplicationWarning))

(.addValue ^ApplicationCall appcall &quot;NAME&quot; &quot;Yield Curve&quot;)
(.addValue ^ApplicationCall appcall &quot;ID&quot; &quot;MyCurve&quot;)
(.addValue ^ApplicationCall appcall &quot;OBJECT&quot; &quot;Curve&quot;)
(.addValue ^ApplicationCall appcall &quot;TYPE&quot; &quot;Yield&quot;)
(.addValue ^ApplicationCall appcall &quot;Now Date&quot; (ApplicationObjectFactory/parseDate &quot;26-Oct-2023&quot;))
(.addValue ^ApplicationCall appcall &quot;CURRENCY&quot; &quot;USD&quot;)
(.addValue ^ApplicationCall appcall &quot;RATE&quot; 0.04)

(def outHeaders (into-array String [&quot;timer&quot; &quot;id&quot;]))

(^[ApplicationCall String/1 ApplicationWarning] Application/.call ^Application myapp
                                                                  ^ApplicationCall appcall
                                                                  ^String/1 outHeaders
                                                                  ^ApplicationWarning warning)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I can inspect appcall object and it looks totally fine - all the .addValue register correctly with it. But when I evaluate the last form with Application/.call I get an error which I don't understand how to address.. &lt;/p&gt;
&lt;pre&gt;&lt;code&gt; Execution error (IllegalAccessError) at hello/eval10370 (REPL:25).
; failed to access class com.numerix.pro.ApplicationCommon from class hello$eval10370 (com.numerix.pro.ApplicationCommon is in unnamed module of loader 'app'; hello$eval10370 is in unnamed module of loader clojure.lang.DynamicClassLoader @cc01572)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Any help much appreciated! &lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14240/java-interop-issue</guid>
<pubDate>Tue, 12 Nov 2024 19:25:31 +0000</pubDate>
</item>
<item>
<title>seque forces n+2 items ahead of consumer instead of n</title>
<link>https://ask.clojure.org/index.php/14178/seque-forces-n-2-items-ahead-of-consumer-instead-of-n</link>
<description>&lt;p&gt;seque's documentation says:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;The queued seq will produce a concrete seq in the background, and can&lt;br&gt;
get up to n items ahead of the consumer.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It seems to force n+2 items ahead of the consumer.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [producer (fn step [i]
                 (lazy-seq
                   (prn &quot;producer&quot; i)
                   (cons i (step (inc i)))))
      s (seque 1 (producer 0))]
  (Thread/sleep 1000)
  nil)
;=&quot;producer&quot; 0
;=&quot;producer&quot; 1
;=&quot;producer&quot; 2
nil
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Sequences</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14178/seque-forces-n-2-items-ahead-of-consumer-instead-of-n</guid>
<pubDate>Tue, 08 Oct 2024 21:33:17 +0000</pubDate>
</item>
<item>
<title>Accidental breaking change in data.json 2.5.0: previously, read succeeded, now it isn't</title>
<link>https://ask.clojure.org/index.php/14134/accidental-breaking-change-data-json-previously-succeeded</link>
<description>&lt;p&gt;Here is a snippet of code that fails on data.json 2.5.0:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj -Sdeps '{:deps {org.clojure/data.json {:mvn/version &quot;2.5.0&quot;}}}' -M -e '((requiring-resolve (quote clojure.data.json/read)) (clojure.lang.LineNumberingPushbackReader. (java.io.StringReader. &quot;[\n  {\n    \&quot;name\&quot;: \&quot;position\&quot;,\n    \&quot;type\&quot;: \&quot;float32\&quot;,\n    \&quot;count\&quot;: 3,\n    \&quot;data\&quot;: [0,0,0]\n  },\n  {\n    \&quot;name\&quot;: \&quot;normal\&quot;,\n    \&quot;type\&quot;: \&quot;float32\&quot;,\n    \&quot;count\&quot;: 3,\n    \&quot;data\&quot;: [0,0,0]\n  },\n  {\n    \&quot;name\&quot;: \&quot;texcoord0\&quot;,\n    \&quot;type\&quot;: \&quot;float32\&quot;,\n    \&quot;count\&quot;: 2,\n    \&quot;data\&quot;: [0,0]\n  }\n]&quot;)))'

Execution error (IOException) at java.io.PushbackReader/unread (PushbackReader.java:166).
Pushback buffer overflow
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same code succeeds on 2.4.0:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj -Sdeps '{:deps {org.clojure/data.json {:mvn/version &quot;2.4.0&quot;}}}' -M -e '((requiring-resolve (quote clojure.data.json/read)) (clojure.lang.LineNumberingPushbackReader. (java.io.StringReader. &quot;[\n  {\n    \&quot;name\&quot;: \&quot;position\&quot;,\n    \&quot;type\&quot;: \&quot;float32\&quot;,\n    \&quot;count\&quot;: 3,\n    \&quot;data\&quot;: [0,0,0]\n  },\n  {\n    \&quot;name\&quot;: \&quot;normal\&quot;,\n    \&quot;type\&quot;: \&quot;float32\&quot;,\n    \&quot;count\&quot;: 3,\n    \&quot;data\&quot;: [0,0,0]\n  },\n  {\n    \&quot;name\&quot;: \&quot;texcoord0\&quot;,\n    \&quot;type\&quot;: \&quot;float32\&quot;,\n    \&quot;count\&quot;: 2,\n    \&quot;data\&quot;: [0,0]\n  }\n]&quot;)))'
[{&quot;name&quot; &quot;position&quot;, &quot;type&quot; &quot;float32&quot;, &quot;count&quot; 3, &quot;data&quot; [0 0 0]} {&quot;name&quot; &quot;normal&quot;, &quot;type&quot; &quot;float32&quot;, &quot;count&quot; 3, &quot;data&quot; [0 0 0]} {&quot;name&quot; &quot;texcoord0&quot;, &quot;type&quot; &quot;float32&quot;, &quot;count&quot; 2, &quot;data&quot; [0 0]}]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The gist of the problem: previously, Clojure's line numbering pushback reader could be used as an input to &lt;code&gt;read&lt;/code&gt;. Now it can't: it throws an exception.&lt;/p&gt;
&lt;p&gt;For reference, this is a json repro (a valid json!):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;[
  {
    &quot;name&quot;: &quot;position&quot;,
    &quot;type&quot;: &quot;float32&quot;,
    &quot;count&quot;: 3,
    &quot;data&quot;: [0,0,0]
  },
  {
    &quot;name&quot;: &quot;normal&quot;,
    &quot;type&quot;: &quot;float32&quot;,
    &quot;count&quot;: 3,
    &quot;data&quot;: [0,0,0]
  },
  {
    &quot;name&quot;: &quot;texcoord0&quot;,
    &quot;type&quot;: &quot;float32&quot;,
    &quot;count&quot;: 2,
    &quot;data&quot;: [0,0]
  }
]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And, the formatted code: that uses the json:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(clojure.data.json/read 
  (clojure.lang.LineNumberingPushbackReader.
    (java.io.StringReader. &quot;...&quot;)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It seems the problem is introduced in &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/DJSON-50&quot;&gt;https://clojure.atlassian.net/browse/DJSON-50&lt;/a&gt;&lt;/p&gt;
</description>
<category>data.json</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14134/accidental-breaking-change-data-json-previously-succeeded</guid>
<pubDate>Wed, 25 Sep 2024 15:46:20 +0000</pubDate>
</item>
<item>
<title>The new array class syntax in 1.12 doesn't seem to be supported by definterface meta tags</title>
<link>https://ask.clojure.org/index.php/14083/array-class-syntax-doesnt-seem-supported-definterface-meta</link>
<description>&lt;p&gt;Noticed by user yuhan in slack &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1KBA2/p1724499452475139&quot;&gt;https://clojurians.slack.com/archives/C03S1KBA2/p1724499452475139&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;❯ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.12.0-rc1&quot;}}}'
Clojure 1.12.0-rc1
user=&amp;gt; (definterface Foo (^String/1 bar []))
user.Foo
user=&amp;gt; (reify Foo (bar [this]))
Syntax error (ClassNotFoundException) compiling reify* at (REPL:1:1).
java.lang.String.1
user=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14083/array-class-syntax-doesnt-seem-supported-definterface-meta</guid>
<pubDate>Sat, 24 Aug 2024 12:30:36 +0000</pubDate>
</item>
<item>
<title>New add-lib in Clojure 1.12 doesn't load data readers brought by the lib</title>
<link>https://ask.clojure.org/index.php/14068/new-add-lib-clojure-doesnt-load-data-readers-brought-the-lib</link>
<description>&lt;p&gt;I see that the new &lt;code&gt;add-lib&lt;/code&gt; in Clojure 1.12 doesn't call &lt;code&gt;clojure.core/load-data-readers&lt;/code&gt; (like clojure.core does on loading) so if you bring libraries that have data-readers you can't use them.&lt;/p&gt;
&lt;p&gt;Calling &lt;code&gt;clojure.core/load-data-readers&lt;/code&gt; from the repl doesn't solve the issue since it changes &lt;code&gt;*data-readers*&lt;/code&gt; root value which is already being shadowed by clojure.main/repl.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.12.0-rc1&quot;} com.github.flow-storm/flow-storm-dbg {:mvn/version &quot;3.17.2&quot;}}}'
Clojure 1.12.0-rc1
user=&amp;gt; *data-readers*
{trace #'flow-storm.api/read-trace-tag, ctrace #'flow-storm.api/read-ctrace-tag, rtrace #'flow-storm.api/read-rtrace-tag, tap #'flow-storm.api/read-tap-tag, tap-stack-trace #'flow-storm.api/read-tap-stack-trace-tag, flow-storm.types/value-ref #'flow-storm.types/make-value-ref, amalloy/ring-buffer #'amalloy.ring-buffer/read-method}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;now with add-lib :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.12.0-rc1&quot;}}}'                                                             
Clojure 1.12.0-rc1
user=&amp;gt; (add-lib 'com.github.flow-storm/flow-storm-dbg {:mvn/version &quot;3.17.2&quot;})
[...]
user=&amp;gt; *data-readers*
{}
user=&amp;gt; (#'clojure.core/load-data-readers)
{trace #'flow-storm.api/read-trace-tag, ctrace #'flow-storm.api/read-ctrace-tag, rtrace #'flow-storm.api/read-rtrace-tag, tap #'flow-storm.api/read-tap-tag, tap-stack-trace #'flow-storm.api/read-tap-stack-trace-tag, flow-storm.types/value-ref #'flow-storm.types/make-value-ref, amalloy/ring-buffer #'amalloy.ring-buffer/read-method}
user=&amp;gt; *data-readers*
{}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The only way I see to bring in data-readers with add-lib is by starting a sub-repl :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.12.0-rc1&quot;}}}'
Clojure 1.12.0-rc1
user=&amp;gt; (add-lib 'com.github.flow-storm/flow-storm-dbg {:mvn/version &quot;3.17.2&quot;})
[...]
user=&amp;gt; (binding [*data-readers* (#'clojure.core/load-data-readers)] (clojure.main/repl))
user=&amp;gt; *data-readers*
{trace #'flow-storm.api/read-trace-tag, ctrace #'flow-storm.api/read-ctrace-tag, rtrace #'flow-storm.api/read-rtrace-tag, tap #'flow-storm.api/read-tap-tag, tap-stack-trace #'flow-storm.api/read-tap-stack-trace-tag, flow-storm.types/value-ref #'flow-storm.types/make-value-ref, amalloy/ring-buffer #'amalloy.ring-buffer/read-method}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;which won't work with nrepl tooling.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14068/new-add-lib-clojure-doesnt-load-data-readers-brought-the-lib</guid>
<pubDate>Tue, 20 Aug 2024 20:42:06 +0000</pubDate>
</item>
<item>
<title>ClojureScript compiler does not transpile &quot;es8&quot; closure libraries</title>
<link>https://ask.clojure.org/index.php/14063/clojurescript-compiler-does-transpile-closure-libraries</link>
<description>&lt;p&gt;The ClojureScript compiler determines the type of the Closure library in the &lt;code&gt;transpile&lt;/code&gt; function. However, &lt;code&gt;:es8&lt;/code&gt;is not implemented.&lt;/p&gt;
&lt;p&gt;I have a fix for this, when a bug number has been assigned.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;br&gt;
Hadil&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14063/clojurescript-compiler-does-transpile-closure-libraries</guid>
<pubDate>Tue, 20 Aug 2024 17:42:31 +0000</pubDate>
</item>
<item>
<title>defn rejects arity with args vector [&amp;form]</title>
<link>https://ask.clojure.org/index.php/14057/defn-rejects-arity-with-args-vector-form</link>
<description>&lt;p&gt;Here's the smallest case, but it seems to happen no matter how many other arities are provided or whether list or vector syntax is used for the arity.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (clojure-version)
&quot;1.12.0-rc1&quot;
user=&amp;gt; (defn f [&amp;amp;form])
Unexpected error (IndexOutOfBoundsException) macroexpanding defn at (REPL:1:1).
null
user=&amp;gt; *e
#error {
 :cause nil
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message &quot;Unexpected error macroexpanding defn at (1:1).&quot;
   :data #:clojure.error{:phase :macroexpansion, :line 1, :column 1, :source &quot;NO_SOURCE_PATH&quot;, :symbol defn}
   :at [clojure.lang.Compiler macroexpand1 &quot;Compiler.java&quot; 7551]}
  {:type java.lang.IndexOutOfBoundsException
   :message nil
   :at [clojure.lang.RT subvec &quot;RT.java&quot; 1634]}]
 :trace
 [[clojure.lang.RT subvec &quot;RT.java&quot; 1634]
  [clojure.core$sigs$asig__5505 invoke &quot;core.clj&quot; 235]
  [clojure.core$sigs invokeStatic &quot;core.clj&quot; 259]
  [clojure.core$defn__5514 invokeStatic &quot;core.clj&quot; 317]
  [clojure.core$defn__5514 doInvoke &quot;core.clj&quot; 294]
  [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 149]
  [clojure.lang.Var applyTo &quot;Var.java&quot; 707]
  [clojure.lang.Compiler macroexpand1 &quot;Compiler.java&quot; 7525]
  [clojure.lang.Compiler macroexpand &quot;Compiler.java&quot; 7598]
  [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7684]
  [clojure.lang.Compiler eval &quot;Compiler.java&quot; 7655]
  [clojure.core$eval invokeStatic &quot;core.clj&quot; 3232]
  [clojure.core$eval invoke &quot;core.clj&quot; 3228]
  [clojure.main$repl$read_eval_print__9240$fn__9243 invoke &quot;main.clj&quot; 437]
  [clojure.main$repl$read_eval_print__9240 invoke &quot;main.clj&quot; 437]
  [clojure.main$repl$fn__9249 invoke &quot;main.clj&quot; 459]
  [clojure.main$repl invokeStatic &quot;main.clj&quot; 459]
  [clojure.main$repl_opt invokeStatic &quot;main.clj&quot; 523]
  [clojure.main$main invokeStatic &quot;main.clj&quot; 668]
  [clojure.main$main doInvoke &quot;main.clj&quot; 617]
  [clojure.lang.RestFn invoke &quot;RestFn.java&quot; 400]
  [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 152]
  [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 135]
  [clojure.lang.Var applyTo &quot;Var.java&quot; 707]
  [clojure.main main &quot;main.java&quot; 40]]}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Macros</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14057/defn-rejects-arity-with-args-vector-form</guid>
<pubDate>Mon, 19 Aug 2024 21:05:00 +0000</pubDate>
</item>
<item>
<title>clojure.pprint/pprint converts unquote+deref to unquote-splicing</title>
<link>https://ask.clojure.org/index.php/14053/clojure-pprint-pprint-converts-unquote-deref-unquote-splicing</link>
<description>&lt;p&gt;This is very unusual syntax but pretty-printing it does not round-trip.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clj -Sforce -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.11.4&quot;}}}'
Clojure 1.11.4
user=&amp;gt; (require '[clojure.pprint :as pp])
nil
user=&amp;gt; (-&amp;gt; &quot;~ @a&quot; read-string pp/pprint)
~@a
nil
user=&amp;gt; (-&amp;gt; '~ @a)
(clojure.core/unquote (clojure.core/deref a))
user=&amp;gt; (-&amp;gt; '~ @a pp/pprint with-out-str read-string)
(clojure.core/unquote-splicing a)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14053/clojure-pprint-pprint-converts-unquote-deref-unquote-splicing</guid>
<pubDate>Mon, 12 Aug 2024 23:25:23 +0000</pubDate>
</item>
<item>
<title>Why does clojure.core/newline not respect *flush-on-newline*?</title>
<link>https://ask.clojure.org/index.php/14044/why-does-clojure-core-newline-not-respect-flush-on-newline</link>
<description>&lt;p&gt;Calling &lt;code&gt;(newline)&lt;/code&gt; appends a newline to the output stream but does not flush it &lt;code&gt;*flush-on-newline*&lt;/code&gt; is bound to &lt;code&gt;true&lt;/code&gt; (the default).&lt;/p&gt;
&lt;p&gt;Instead, only &lt;code&gt;clojure.core/prn&lt;/code&gt; mentions &lt;code&gt;*flush-on-newline*&lt;/code&gt; in its docstring and the check and &lt;code&gt;(flush)&lt;/code&gt; call is explicit there.&lt;/p&gt;
&lt;p&gt;Why is this?&lt;/p&gt;
&lt;p&gt;Also, &lt;code&gt;println&lt;/code&gt; does not mention that it &lt;code&gt;Observes *flush-on-newline*&lt;/code&gt; like &lt;code&gt;prn&lt;/code&gt; does, and it doesn't hint that it calls &lt;code&gt;prn&lt;/code&gt; which does, since it says &lt;code&gt;Same as print followed by (newline)&lt;/code&gt; which isn't actually true.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14044/why-does-clojure-core-newline-not-respect-flush-on-newline</guid>
<pubDate>Wed, 07 Aug 2024 23:09:06 +0000</pubDate>
</item>
<item>
<title>Using integer parameters in deftype annotations</title>
<link>https://ask.clojure.org/index.php/13998/using-integer-parameters-in-deftype-annotations</link>
<description>&lt;p&gt;I am trying to use a Java library that uses annotations on Java classes and methods, so I pass to it deftypes with annotated methods. Some of the annotations require using integer parameters and it seems there is no  convenient way to do this in Clojure. The code I am trying is something like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(deftype SomeType []
  (^{Retention RetentionPolicy/RUNTIME
     SomeAnnotationClass {:order 1} }
   someMethod [_]...)) 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;:order 1&lt;/code&gt; part causes an exception:&lt;/p&gt;
&lt;p&gt; &lt;code&gt;Incorrectly typed data found for annotation element ... (Found data of type java.lang.Long[1])&lt;/code&gt; &lt;/p&gt;
&lt;p&gt;This happens because the java library expects that &lt;code&gt;:order&lt;/code&gt; would have a java.lang.Integer value, but Clojure creates a java.lang.Long. If I try (int 1)  instead of 1, I get another exception.&lt;/p&gt;
&lt;p&gt;I asked for help on clojurians Slack, and it was suggested that I use &lt;code&gt;#java.lang.Integer[1]&lt;/code&gt; instead of simply 1. This works, but it would be nice to have a more intuitive way to do this.&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13998/using-integer-parameters-in-deftype-annotations</guid>
<pubDate>Sun, 30 Jun 2024 18:44:17 +0000</pubDate>
</item>
<item>
<title>Deadlock with clojure.java.shell/sh</title>
<link>https://ask.clojure.org/index.php/13974/deadlock-with-clojure-java-shell-sh</link>
<description>&lt;p&gt;The &lt;code&gt;clojure.java.shell/sh&lt;/code&gt; function has this construct at the end:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(with-open [stdout (.getInputStream proc)
            stderr (.getErrorStream proc)]
  (let [out (future (stream-to-enc stdout out-enc))
        err (future (stream-to-string stderr))
        exit-code (.waitFor proc)]
    {:exit exit-code :out @out :err @err}))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;So the outputs of a process are read in two futures, while the current thread awaits for process to end (and generate exit code). If an exception happens during an execution of a future, that exception is stored and thrown (wrapped in ExecutionException), when futures are derefed (&lt;strong&gt;in this case this is after process ends&lt;/strong&gt;). &lt;/p&gt;
&lt;p&gt;I've had a case where I was calling git with &lt;code&gt;sh&lt;/code&gt; and the generated output was large enough to produce &lt;code&gt;OutOfMemoryError&lt;/code&gt;. And here's where you get a &quot;deadlock&quot; (it's not one technically).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Git was shoveling data into pipe, while Java process was reading it in the future, main thread was awaiting process end&lt;/li&gt;
&lt;li&gt;Future reading &lt;code&gt;out&lt;/code&gt; encounters an OutOfMemory exception, it is stored and &lt;code&gt;out&lt;/code&gt; reader loop terminates&lt;/li&gt;
&lt;li&gt;Pipe buffer between processes becomes full, as git is writing but nobody is reading anymore&lt;/li&gt;
&lt;li&gt;Git stalls indefinitely trying to write to pipe&lt;/li&gt;
&lt;li&gt;Java process main thread awaits git process end indefinitely&lt;/li&gt;
&lt;li&gt;The future is never derefed so no exception stacktrace or message is ever produced&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This can happen with any type of exception during one of those 2 future's reads. Another realistic scenario would be if I specify an encoding and underlying process returns some bytes that cannot be parsed in that encoding.&lt;/p&gt;
&lt;p&gt;This &quot;bug&quot; was quite frustrating because there is no error message and very little indication of what is wrong. In my case it happened sporadically in production and it was quite hard to track down.&lt;/p&gt;
&lt;p&gt;I don't know what the remedy is, but it might be smart to do some sort of mitigation for this.&lt;/p&gt;
</description>
<category>IO</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13974/deadlock-with-clojure-java-shell-sh</guid>
<pubDate>Mon, 17 Jun 2024 15:19:36 +0000</pubDate>
</item>
<item>
<title>Locals clearing + forcing a delay recursively results in NPE</title>
<link>https://ask.clojure.org/index.php/13930/locals-clearing-forcing-a-delay-recursively-results-in-npe</link>
<description>&lt;p&gt;Discovered by Ambrose Bonnaire-Sergeant (@ambrosebs).&lt;/p&gt;
&lt;p&gt;Given this convoluted example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [f +
      p (promise)
      d (delay (f) @@p)]
 (deliver p d)
 @d)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When executed, it fails with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. Unhandled java.lang.NullPointerException
   Cannot invoke &quot;clojure.lang.IFn.invoke()&quot; because &quot;this.f&quot; is null
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The same error happens with lazy seqs:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [f +
      p (promise)
      d (lazy-seq (f) (first @p))]
  (deliver p d)
  (first d))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The reason in both cases is that locals clearing assigns &lt;code&gt;this.f = null;&lt;/code&gt; right after it is first invoked, so when the recursive call reaches &lt;code&gt;(f)&lt;/code&gt; again, the reference is already nil.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(binding [*compiler-options* {:disable-locals-clearing false}]
  (clj-java-decompiler.core/decompile
   (defn repro []
     (let [f +
        p (promise)
        d (delay (f) @@p)]
    (deliver p d)
    @d))))

=&amp;gt;

@Override
public Object invoke() {
    final Object f = this.f;
    this.f = null;
    ((IFn)f).invoke();
    final IFn fn = (IFn)__deref.getRawRoot();
    final IFn fn2 = (IFn)__deref.getRawRoot();
    final Object p = this.p;
    this.p = null;
    final Object invoke = fn2.invoke(p);
    this = null;
    return fn.invoke(invoke);
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this a bug or undefined behavior?&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13930/locals-clearing-forcing-a-delay-recursively-results-in-npe</guid>
<pubDate>Thu, 30 May 2024 21:11:28 +0000</pubDate>
</item>
<item>
<title>(deftype) blues - private and mutable field access problems</title>
<link>https://ask.clojure.org/index.php/13890/deftype-blues-private-and-mutable-field-access-problems</link>
<description>&lt;p&gt;New to clojure, trying to define an effective class with mutable fields via deftype, definitions below.&lt;/p&gt;
&lt;p&gt;  My program is single threaded, no one else will ever use my code, promised. I know all the advantages of immutability, but this program makes over 500,000,000 updates, so the GC would be the main actor, not my code. I've tried that.&lt;/p&gt;
&lt;p&gt;Two problems I've got at run time.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;*1. ; Execution error (IllegalArgumentException) at layout.core.Individual/idivlCopy (core.clj:161).
    ; No matching field found: fitness for class layout.core.Individual
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I understand that the fields of a deftype are not public, but the code of idivlCopy is in the deftype itself. It seems to me, that the runtime knows (.fitness this) but not (.fitness that).&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;What is the rationale of this behaviour and how can I get around it?&lt;/li&gt;
&lt;li&gt;How can I access the private protected fields (of that) from the private (i.e. deftype) code area?!&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;*2. ; Execution error (ClassCastException) at layout.core.Individual/idivlSwap (core.clj:173).
           ; class clojure.core.Vec cannot be cast to class clojure.lang.IEditableCollection
           ;    (clojure.core.Vec and clojure.lang.IEditableCollection are in unnamed module of loader 'app')
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;`&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The annotations tell that both fields are volatile-mutable. Why  is this not known at run time for the chromosome vector? Why can't I (assoc! ) my volatile-mutable chromosome vector-of :char    -s?&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;pre&gt;&lt;code&gt;(definterface IIndividual

  (idivlCopy [that])                      ; Copies that Individual to this
  (idivlSwap [^Integer xP, ^Integer xQ])) ; Swaps two genes in the chromosome
  ; and somme more.
)

(deftype Individual                ; An individual has a fitness value and a chromosome
  [^{:volatile-mutable true}  ^Integer fitness,       ; Integer
   ^{:volatile-mutable true}           chromosome]    ; vector-of :char
 
  IIndividual

	:
	.

  (idivlCopy         ; Copies that Individual to this
    [_, that] 
*1  (set! fitness    (.fitness    that))         ; (set! fitness  999) worked!!
    (set! chromosome (.chromosome that))
    nil)

  (idivlSwap         ; Swaps the genes in the chromosome at alleles P and Q
    [this,
     ^Integer iP,                 ; index of allele P
     ^Integer iQ]                 ; index of allele Q
    (let [gP (chromosome iP),     ; gene  at allele P
          gQ (chromosome iQ)]     ; gene  at allele Q
*2    (assoc! chromosome iP gQ)
      (assoc! chromosome iQ gP)
      nil))

    ; and some more
    :
	.
)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13890/deftype-blues-private-and-mutable-field-access-problems</guid>
<pubDate>Mon, 20 May 2024 18:15:40 +0000</pubDate>
</item>
<item>
<title>tools.tools install-latest throws sha error with :coord  and never upgrades with :tool</title>
<link>https://ask.clojure.org/index.php/13882/tools-tools-install-latest-throws-error-coord-never-upgrades</link>
<description>&lt;p&gt;Thanks for &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/TDEPS-253&quot;&gt;https://clojure.atlassian.net/browse/TDEPS-253&lt;/a&gt;, however I noticed it doesn't quite work as expected for a fresh install (with &lt;code&gt;:coord&lt;/code&gt;); I get an error due to a missing sha, contrary to the doc string &quot;git coords may omit sha&quot;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj -Ttools install-latest \
:lib org/tool-name \
:coord '{:git/url &quot;git@gitlab.int.org.com:group/subgroup/tool-name.git&quot;}' \
:as tool-name

=&amp;gt;
Execution error (ExceptionInfo) at clojure.tools.deps.extensions.git/eval1656$fn (git.clj:79).
Library org/tool-name has coord with missing sha
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I also found upgrading a tool with saved coordinates (&lt;code&gt;clj -Ttools install-latest :tool tool-name&lt;/code&gt;) always results in &quot;Skipping, newest installed&quot; (because passing the &lt;code&gt;coord&lt;/code&gt; returned by &lt;code&gt;parse-install-latest-args&lt;/code&gt; to &lt;code&gt;install-1&lt;/code&gt; means &lt;code&gt;ext/find-all-versions&lt;/code&gt; is never evaluated). Looks like this issue would affect tools with auto resolved git urls too.&lt;/p&gt;
</description>
<category>Clojure CLI</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13882/tools-tools-install-latest-throws-error-coord-never-upgrades</guid>
<pubDate>Mon, 13 May 2024 10:24:47 +0000</pubDate>
</item>
<item>
<title>`(s/gen ratio?)` throws exceptions</title>
<link>https://ask.clojure.org/index.php/13877/s-gen-ratio-throws-exceptions</link>
<description>&lt;p&gt;&lt;code&gt;(s/gen ratio?)&lt;/code&gt; is &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/spec.alpha/blob/c630a0b8f1f47275e1a476dcdf77507316bad5bc/src/main/clojure/clojure/spec/gen/alpha.clj#L187&quot;&gt;implemented&lt;/a&gt; as &lt;code&gt;(gen/such-that ratio? gen/ratio)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The problem is that about 10% of the time &lt;code&gt;gen/ratio&lt;/code&gt; returns a whole number, which fails the &lt;code&gt;ratio?&lt;/code&gt; predicate. If that happens 10 times in a row, &lt;code&gt;gen/such-that&lt;/code&gt; throws an exception.&lt;/p&gt;
&lt;p&gt;With a large enough sample size, &lt;code&gt;(s/gen ratio?)&lt;/code&gt; reliably fails:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(dorun (gen/sample (s/gen ratio?) 10000000))

Execution error (ExceptionInfo) at clojure.test.check.generators/fn (generators.cljc:435).
Couldn't satisfy such-that predicate after 10 tries.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A quick fix is to increase the &lt;code&gt;max-tries&lt;/code&gt; param for &lt;code&gt;such-that&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(dorun (gen/sample (gen/such-that ratio? gen/ratio 100) 10000000))

=&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I do however also find it odd that &lt;code&gt;(s/gen ratio?)&lt;/code&gt; always generates &lt;code&gt;Ratio&lt;/code&gt;s, but &lt;code&gt;gen/ratio&lt;/code&gt; generates a mixture of ratios and integers. So perhaps a better fix would be to update &lt;code&gt;gen/ratio&lt;/code&gt; to not generate integers?&lt;/p&gt;
</description>
<category>Spec</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13877/s-gen-ratio-throws-exceptions</guid>
<pubDate>Wed, 08 May 2024 07:44:49 +0000</pubDate>
</item>
</channel>
</rss>