<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Questions without answers in Clojure</title>
<link>https://ask.clojure.org/index.php/unanswered/clojure</link>
<description></description>
<item>
<title>Possibly avoidable identity call to force instance method on Class literals</title>
<link>https://ask.clojure.org/index.php/15155/possibly-avoidable-identity-force-instance-method-literals</link>
<description>&lt;p&gt;As of Clojure 1.13.0-alpha2, &lt;code&gt;(.method ClassName)&lt;/code&gt; expands to &lt;code&gt;(.method ^Class (identity ClassName))&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This is to force &lt;code&gt;(.method ClassName)&lt;/code&gt; to always be an instance method. Without this, it would expand to &lt;code&gt;(. ClassName method)&lt;/code&gt;, which may instead be interpreted as a static method.&lt;/p&gt;
&lt;p&gt;For example, &lt;code&gt;(.getMethods String)&lt;/code&gt; expands to &lt;code&gt;(.getMethods ^Class (identity String))&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This was introduced in these two commits:&lt;br&gt;
- &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/commit/f95175264df36c3d8fe2113aa9af92cda0f2f5c8&quot;&gt;force instance member interpretation of (.method ClassName), e.g. (.getMethods String) works&lt;/a&gt;&lt;br&gt;
- &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/commit/e45046da8f7fef82157b58af54d1ac6de8e31160&quot;&gt;added autohinting to Class in macroexpansion of (.instanceMethodOfClass Classname) calls&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Since then, Clojure has added support for qualified methods which we can use to reliably propagate the tag without any runtime changes. For example, expanding to &lt;code&gt;(Class/.getMethods String)&lt;/code&gt; is now equivalent to &lt;code&gt;(.getMethods ^Class (identity String))&lt;/code&gt; in terms of tag propagation.&lt;/p&gt;
&lt;p&gt;I have a proof-of-concept &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/frenchy64/clojure/pull/52/changes&quot;&gt;here&lt;/a&gt; that includes disassembled and decompiled output before and after the change. The net effect of using qualified methods in this case under direct linking is a removal of a single method call to &lt;code&gt;identity&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;   3: invokestatic  #20                 // Method clojure/core$identity.invokeStatic:(Ljava/lang/Object;)Ljava/lang/Object;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The effect is more substantial without direct linking (not included in the PR), with &lt;code&gt;clojure.core/identity&lt;/code&gt; also being added to the static initializer.&lt;/p&gt;
&lt;p&gt;I've also experimented with expanding to &lt;code&gt;(. (do String) getMethods)&lt;/code&gt; (see earlier commits in that PR), which seems to also work and might be another approach.&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15155/possibly-avoidable-identity-force-instance-method-literals</guid>
<pubDate>Thu, 02 Jul 2026 23:47:10 +0000</pubDate>
</item>
<item>
<title>Syntax-quoted lists can return nil, differs from ClojureScript</title>
<link>https://ask.clojure.org/index.php/15152/syntax-quoted-lists-can-return-differs-from-clojurescript</link>
<description>&lt;p&gt;Syntax quoted lists can return &lt;code&gt;nil&lt;/code&gt; if only empty seqables are spliced into it:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.5
user=&amp;gt; `(~@[])
nil
user=&amp;gt; `(~@[] ~@[])
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, the implementation then ensures syntax-quoted empty lists are not nil:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.5
user=&amp;gt; `()
()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;ClojureScript returns an empty list in these cases:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;`(~@[])
=&amp;gt; ()
`(~@[] ~@[])
=&amp;gt; ()
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The expansion of syntax quote itself is not necessarily a problem if it differs between platforms, but here the evaluation of the expansion differs. This can cause macros to behave differently between platforms (e.g., JVM Clojure vs bootstrapped cljs).&lt;/p&gt;
&lt;p&gt;This behavior seems to be present with all versions of Clojure &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/f85444e6f890eb585e598efefdbd84727427e0a4/src/jvm/clojure/lang/LispReader.java#L731&quot;&gt;including 1.0.0&lt;/a&gt;, so perhaps the ship has sailed here. I went searching for an existing issue or documentation and AFAICT only &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-1425&quot;&gt;CLJ-1425&lt;/a&gt; mentions this oddity.&lt;/p&gt;
&lt;p&gt;The reference docs for &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/reader#syntax-quote&quot;&gt;Syntax Quote&lt;/a&gt; also seem to contradict this behavior:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;For Lists/Vectors/Sets/Maps, syntax-quote establishes a template of the corresponding data structure.&lt;/p&gt;
&lt;/blockquote&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15152/syntax-quoted-lists-can-return-differs-from-clojurescript</guid>
<pubDate>Sun, 28 Jun 2026 20:43:55 +0000</pubDate>
</item>
<item>
<title>Consider including a built-in wrapper around `java.net.http.HttpClient` in future versions of Clojure</title>
<link>https://ask.clojure.org/index.php/15129/consider-including-wrapper-around-httpclient-versions-clojure</link>
<description>&lt;p&gt;Java 9 introduced &lt;code&gt;java.net.http.HttpClient&lt;/code&gt;[1] with support for HTTP/1.1, HTTP/2 as well as WebSocket along with other features. It was later standardized in Java 11[2] and has become one of the top picks for Java programs. The latest version of the HTTP client shipped with Java 26 also added support for HTTP/3.[3] &lt;/p&gt;
&lt;p&gt;It would be nice for future versions of Clojure that are based on Java 11+ to include a new namespace with wrapper functions around &lt;code&gt;java.net.http.HttpClient&lt;/code&gt; to make it easier (without all the OOP ceremonies) to work with HTTP in Clojure programs out of the box without relying on any 3rd-party libraries.&lt;/p&gt;
&lt;p&gt;Examples of prior art:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/gnarroway/hato&quot;&gt;https://github.com/gnarroway/hato&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/schmee/java-http-clj&quot;&gt;https://github.com/schmee/java-http-clj&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/babashka/http-client&quot;&gt;https://github.com/babashka/http-client&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://central.sonatype.com/artifact/com.cognitect/http-client&quot;&gt;https://central.sonatype.com/artifact/com.cognitect/http-client&lt;/a&gt;&lt;br&gt;
(upcoming?)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;[1] &lt;a rel=&quot;nofollow&quot; href=&quot;https://openjdk.org/jeps/110&quot;&gt;https://openjdk.org/jeps/110&lt;/a&gt;&lt;br&gt;
[2] &lt;a rel=&quot;nofollow&quot; href=&quot;https://openjdk.org/jeps/321&quot;&gt;https://openjdk.org/jeps/321&lt;/a&gt;&lt;br&gt;
[3] &lt;a rel=&quot;nofollow&quot; href=&quot;https://openjdk.org/jeps/517&quot;&gt;https://openjdk.org/jeps/517&lt;/a&gt;&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15129/consider-including-wrapper-around-httpclient-versions-clojure</guid>
<pubDate>Mon, 08 Jun 2026 01:37:14 +0000</pubDate>
</item>
<item>
<title>Request: allow a user function to be specified as the target of clojure.main/report-error</title>
<link>https://ask.clojure.org/index.php/15120/request-allow-function-specified-target-clojure-report-error</link>
<description>&lt;p&gt;The three current targets (&lt;code&gt;file&lt;/code&gt;, &lt;code&gt;none&lt;/code&gt;, &lt;code&gt;stderr&lt;/code&gt;) all serialize all of the error data to a string. During development, it would be convenient to be able to define a function that is called with the exception instance. This function might capture additional application state, or open a window in the user's editor, etc.&lt;/p&gt;
&lt;p&gt;Note that it is not possible to work around this by replacing &lt;code&gt;report-error&lt;/code&gt; itself because the entire clojure.main namespace is AOT-compiled, so &lt;code&gt;alter-var-root&lt;/code&gt; has no effect.&lt;/p&gt;
&lt;p&gt;See &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure-emacs/cider/issues/3850&quot;&gt;https://github.com/clojure-emacs/cider/issues/3850&lt;/a&gt; for an example where this feature would be helpful.&lt;/p&gt;
&lt;p&gt;Related Slack thread: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1KBA2/p1779991120304049&quot;&gt;https://clojurians.slack.com/archives/C03S1KBA2/p1779991120304049&lt;/a&gt;&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15120/request-allow-function-specified-target-clojure-report-error</guid>
<pubDate>Tue, 02 Jun 2026 23:53:32 +0000</pubDate>
</item>
<item>
<title>Feature Request:Make anonymous fn/reify class name IDs per namespace instead of one global counter</title>
<link>https://ask.clojure.org/index.php/14935/feature-request-anonymous-namespace-instead-global-counter</link>
<description>&lt;p&gt;  Compiled anonymous functions and reify classes get names like ns$fn__4532, where the numeric suffix comes from a global AtomicInteger counter&lt;br&gt;
  (RT.nextID()).&lt;/p&gt;
&lt;p&gt; This counter is shared across the entire runtime and is consumed by fn classes, reify classes, constants tables, gensyms, etc.&lt;/p&gt;
&lt;p&gt;  The problem is that because the counter is global, any code change shifts the IDs for everything compiled after it. This makes profiling across builds&lt;br&gt;
  really painful, you can't meaningfully compare flame graphs because all the class names change even in code you didn't touch.&lt;/p&gt;
&lt;p&gt;  I'd like to propose scoping the ID counter per-namespace instead. Since the namespace is already part of the class name prefix, uniqueness is still&lt;br&gt;
  guaranteed. This would eliminate the cascading effect across unchanged namespaces and make profiling diffs actually useful.&lt;/p&gt;
&lt;p&gt;I'm not sure what's the downsides of this, but from what I saw of AtomicInteger, it isn't used a lot to break things.&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14935/feature-request-anonymous-namespace-instead-global-counter</guid>
<pubDate>Wed, 18 Feb 2026 15:34:38 +0000</pubDate>
</item>
<item>
<title>definterface doesn't expose gen-interface's :extends for interface extension</title>
<link>https://ask.clojure.org/index.php/14903/definterface-doesnt-interfaces-extends-interface-extension</link>
<description>&lt;p&gt;gen-interface allow :extends to specify one or more interfaces, which will be extended by this interface. &lt;/p&gt;
&lt;p&gt;definterface doesn't expose this.&lt;/p&gt;
&lt;p&gt;Use case is working with primitives (where protocols don’t help), to get things to dispatch nicely in a zero boxing primitive transducer implementation.&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14903/definterface-doesnt-interfaces-extends-interface-extension</guid>
<pubDate>Mon, 26 Jan 2026 19:49:08 +0000</pubDate>
</item>
<item>
<title>Octal escape sequence decoding in strings does not stop at non-octal digit</title>
<link>https://ask.clojure.org/index.php/14846/octal-escape-sequence-decoding-strings-does-stop-octal-digit</link>
<description>&lt;p&gt;Strings suppose to support standard Java escape sequences, including octal escape sequence: [0-7]{1,3} &lt;/p&gt;
&lt;p&gt;In Java decoding of octal sequences stop at the first non-octal digit or any other character if there are 1 or two octal digits in the escape sequence. For example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jshell&amp;gt; &quot;\18&quot;
$1 ==&amp;gt; &quot;\0018&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But Clojure reads up to 3 potentially octal digits greedily resulting in wrongly consuming non-octal digits:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.4
user=&amp;gt; &quot;\18&quot;
Syntax error reading source at (REPL:1:5).
Invalid digit: 8
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;non-octal characters:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.4
user=&amp;gt; &quot;\1d&quot;
Syntax error reading source at (REPL:1:5).
Invalid digit: d
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;And succeed only when there is line terminator or exact three octal digits in supported octal range:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.12.4
user=&amp;gt; &quot;\1&quot;
&quot;&quot;
user=&amp;gt; &quot;\1&quot;
&quot;&quot;
user=&amp;gt; &quot;\12&quot;
&quot;\n&quot;
user=&amp;gt; &quot;\123&quot;
&quot;S&quot;
user=&amp;gt; &quot;\123d&quot;
&quot;Sd&quot;
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14846/octal-escape-sequence-decoding-strings-does-stop-octal-digit</guid>
<pubDate>Thu, 18 Dec 2025 09:35:53 +0000</pubDate>
</item>
<item>
<title>`(s/gen ...)` caches its failure to load generators and thus is incompatible with `add-lib`</title>
<link>https://ask.clojure.org/index.php/14718/gen-caches-failure-load-generators-thus-incompatible-with</link>
<description>&lt;pre&gt;&lt;code&gt;Clojure 1.12.0
user=&amp;gt; (require '[clojure.spec.alpha :as s])
nil
user=&amp;gt; (s/def ::x #{1 2 3})
:user/x
user=&amp;gt; (s/gen ::x)
Execution error (FileNotFoundException) at user/eval145 (REPL:1).
Could not locate clojure/test/check/generators__init.class, clojure/test/check/generators.clj or clojure/test/check/generators.cljc on classpath.
user=&amp;gt; (add-lib 'org.clojure/test.check)
[org.clojure/test.check]
user=&amp;gt; (s/gen ::x)
Execution error (FileNotFoundException) at user/eval145 (REPL:1).
Could not locate clojure/test/check/generators__init.class, clojure/test/check/generators.clj or clojure/test/check/generators.cljc on classpath.
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>REPL</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14718/gen-caches-failure-load-generators-thus-incompatible-with</guid>
<pubDate>Tue, 23 Sep 2025 16:23:58 +0000</pubDate>
</item>
<item>
<title>clojure -X hangs with agent use</title>
<link>https://ask.clojure.org/index.php/14708/clojure-x-hangs-with-agent-use</link>
<description>&lt;p&gt;Given this repro:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns repro)

(defn exec-fn [_]
  (let [a (agent nil)]
    (prn (-&amp;gt; (java.lang.ProcessHandle/current) (.pid)))
    (send a (fn [_] 3))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;the &lt;code&gt;clojure -X repro/exec-fn&lt;/code&gt; invocation is hanging.&lt;/p&gt;
&lt;p&gt;This seems to be unintentional, given that clojure -X doesn't wait for futures to finish either?&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14708/clojure-x-hangs-with-agent-use</guid>
<pubDate>Wed, 10 Sep 2025 21:02:32 +0000</pubDate>
</item>
<item>
<title>select-keys on nil map</title>
<link>https://ask.clojure.org/index.php/14654/select-keys-on-nil-map</link>
<description>&lt;p&gt;I know that &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/1913/use-transients-with-select-keys-if-possible&quot;&gt;https://ask.clojure.org/index.php/1913/use-transients-with-select-keys-if-possible&lt;/a&gt; exists to optimize &lt;code&gt;select-keys&lt;/code&gt; for many keys, but I noticed that it does a lot of work even if the original map is &lt;code&gt;nil&lt;/code&gt;. Would there be interest in a patch that returns an empty map when given &lt;code&gt;nil&lt;/code&gt;? Something like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn select-keys*
  &quot;Returns a map containing only those entries in map whose key is in keys&quot;
  {:added &quot;1.0&quot;
   :static true}
  [map keyseq]
  (if map
    (loop [ret {} keys (seq keyseq)]
      (if keys
        (let [entry (. clojure.lang.RT (find map (first keys)))]
          (recur
           (if entry
             (conj ret entry)
             ret)
           (next keys)))
        (with-meta ret (meta map))))
    {}))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Collections</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14654/select-keys-on-nil-map</guid>
<pubDate>Fri, 01 Aug 2025 14:42:56 +0000</pubDate>
</item>
<item>
<title>Compiler-generated `foo__init.class` files lack `SourceFile` attribute</title>
<link>https://ask.clojure.org/index.php/14652/compiler-generated-fooinit-class-sourcefile-attribute</link>
<description>&lt;p&gt;Most .class files generated by Clojure contain the expected &lt;a rel=&quot;nofollow&quot; href=&quot;https://docs.oracle.com/javase/specs/jvms/se11/html/jvms-4.html#jvms-4.7.10&quot;&gt;SourceFile&lt;/a&gt; attribute (you can verify with &lt;code&gt;javap -v&lt;/code&gt;). But &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/compilation#_compiling&quot;&gt;__init&lt;/a&gt; classfiles lack this metadata. I asked @alexmiller on Slack, and he suggested I bring it up here.&lt;/p&gt;
&lt;p&gt;The same appears to be true of classes generated via &lt;code&gt;proxy&lt;/code&gt;.&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14652/compiler-generated-fooinit-class-sourcefile-attribute</guid>
<pubDate>Thu, 31 Jul 2025 22:21:18 +0000</pubDate>
</item>
<item>
<title>Skip stacktrace creation in ExceptionInfo</title>
<link>https://ask.clojure.org/index.php/14634/skip-stacktrace-creation-in-exceptioninfo</link>
<description>&lt;p&gt;Many libraries and applications use exceptions as control flow or data collection, which allows for handling complex situations with more consistent and legible code. Some libraries use custom throwables (&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/IGJoshua/farolero&quot;&gt;IGJoshua/farolero&lt;/a&gt;, &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/NoahTheDuke/lazytest&quot;&gt;NoahTheDuke/lazytest&lt;/a&gt;) and some use ExceptionInfos (&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/scgilardi/slingshot/&quot;&gt;scgilardi/slingshot&lt;/a&gt;, &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/fmnoise/flow&quot;&gt;fmnoise/flow&lt;/a&gt;, &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/pangloss/pure-conditioning&quot;&gt;pangloss/pure-conditioning&lt;/a&gt;, &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/exoscale/ex&quot;&gt;exoscale/ex&lt;/a&gt;).&lt;/p&gt;
&lt;p&gt;One of the reasons that libraries reach for custom throwables is because they want to skip creation of a stack trace (which isn't used and would be thrown away immediately). Stack traces in Java are already fairly expensive to create, and then the filtering work done in &lt;code&gt;ExceptionInfo&lt;/code&gt; greatly increases that expense, making them much slower than needed. (There's an Ask about this but I can't find it.) This performance cost pressures developers to use custom throwables if their code will ever be used in a &quot;hot path&quot;, which harms portability and ease of development. (I want to write Clojure, not Java, and I want it to be usable in Clojurescript and Babashka and whatever other dialects might arise.)&lt;/p&gt;
&lt;p&gt;I know that there's a rejected Jira ticket (&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2423&quot;&gt;CLJ-2423&lt;/a&gt;) for supporting the &quot;enableSuppression&quot; flag, but in light of these use-cases, I'd like to bring it up again.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14634/skip-stacktrace-creation-in-exceptioninfo</guid>
<pubDate>Thu, 17 Jul 2025 14:46:52 +0000</pubDate>
</item>
<item>
<title>How best to call long-running tasks from a core.async.flow process?</title>
<link>https://ask.clojure.org/index.php/14621/how-best-call-long-running-tasks-from-core-async-flow-process</link>
<description>&lt;p&gt;I'd like to write to a database as the final process in a core.async.flow flow. The db load can take several minutes. If I do this work directly in the :transform function's thread, flow-monitor can't ping that process for the duration of the load. But if I offload the work to a different thread and return from the :transform function, I can't as easily control back pressure from that process.&lt;/p&gt;
&lt;p&gt;The relevant process currently looks something like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def db-loader
  (flow/map-&amp;gt;step
   {:describe (fn [] {:workload :io
                      :ins {:in &quot;Batched items&quot;}})
    :init     (fn [state] state)
    :transition (fn [state status] state)
    :transform (fn [state _ batch]
                 (t/log! &quot;DB Loader is loading a batch.&quot;)
                 (Thread/sleep 10000) ;; imagine this code writes to the db.
                 (t/log! &quot;DB Loader loaded a batch.&quot;)
                 [state])}))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;A more complete code example is at &lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/tomconnors/245fb69ed757b34502c8d57637db8de2&quot;&gt;https://gist.github.com/tomconnors/245fb69ed757b34502c8d57637db8de2&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Is there a better option for this process?&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14621/how-best-call-long-running-tasks-from-core-async-flow-process</guid>
<pubDate>Wed, 09 Jul 2025 18:31:41 +0000</pubDate>
</item>
<item>
<title>Metadata on quoted forms</title>
<link>https://ask.clojure.org/index.php/14620/metadata-on-quoted-forms</link>
<description>&lt;p&gt;Reader metadata is attached to IObj forms at read time, but if the form is quoted, then the quote form gets the metadata and the quoted form doesn't get the metadata. This means that to attach metadata to forms, you need to write the slightly awkward quote -&amp;gt; metadata -&amp;gt; form instead of the (imo) more natural metadata-&amp;gt; quote -&amp;gt; form.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (meta ^:foo '(1 2 3))
{:line 1 :column 1}
user=&amp;gt; (meta '^:foo (1 2 3))
{:lime 1 :column 1 :foo true}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I know that this is because &lt;code&gt;'&lt;/code&gt; is implemented as a &quot;WrappingReader&quot; and so the former is read as &lt;code&gt;^:foo (quote (1 2 3))&lt;/code&gt; but that feels like an implementation detail leaking through. I think it would be helpful/more consistent if quote passed any metadata to IObjs.&lt;/p&gt;
</description>
<category>Metadata</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14620/metadata-on-quoted-forms</guid>
<pubDate>Sun, 06 Jul 2025 15:29:14 +0000</pubDate>
</item>
<item>
<title>`(even? (range))` hangs</title>
<link>https://ask.clojure.org/index.php/14578/even-range-hangs</link>
<description>&lt;p&gt;It is, of course, an error to call &lt;code&gt;(even? (range))&lt;/code&gt;, but still - I'd much rather prefer a class cast exception. Or the existing &lt;code&gt;IllegalArgumentException&lt;/code&gt;, just without printing the argument. Especially given that the argument could be absolutely anything, including side-effecting lazy collections.&lt;/p&gt;
&lt;p&gt;A couple of other cases like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(array-map (range))
(requiring-resolve (range))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14578/even-range-hangs</guid>
<pubDate>Sun, 08 Jun 2025 11:54:29 +0000</pubDate>
</item>
<item>
<title>Associative destructuring with if-let</title>
<link>https://ask.clojure.org/index.php/14574/associative-destructuring-with-if-let</link>
<description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I'm surprised by the result of this code :&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(if-let [{errors :errors} {}]
    errors
    true) =&amp;gt; nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I would have expected the result to be 'true'.&lt;/p&gt;
&lt;p&gt;As indicated by the result, 'errors' evaluates to nil, but still it's the 'then' arm of the 'if' that is evaluated.&lt;/p&gt;
&lt;p&gt;The guide on destructuring state that &quot;You can utilize destructuring anywhere that there is an explicit or implicit let binding.&quot;, so I'm a bit puzzled.&lt;/p&gt;
&lt;p&gt;Please, enlighten me. Thanks !&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14574/associative-destructuring-with-if-let</guid>
<pubDate>Sat, 07 Jun 2025 17:21:45 +0000</pubDate>
</item>
<item>
<title>Can custom literal collections reach parity with clojure's built in collections?</title>
<link>https://ask.clojure.org/index.php/14474/custom-literal-collections-reach-parity-clojures-collections</link>
<description>&lt;h3&gt;Teaching Old &lt;code&gt;eval&lt;/code&gt; New Tricks&lt;/h3&gt;
&lt;h4&gt;Tagged Literals Promise Extensibility&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;EDN and Tagged Literals:&lt;/strong&gt;&lt;br&gt;
- In EDN, tagged literals deliver complete extensibility.&lt;br&gt;
- When processing EDN data, custom types created with tagged readers achieve parity with built-in literals.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Clojure’s Syntax and Tagged Literals:&lt;/strong&gt;&lt;br&gt;
- Clojure's syntax, as a superset of EDN, includes tagged literals.&lt;br&gt;
- &lt;strong&gt;Key Differences:&lt;/strong&gt;&lt;br&gt;
  - EDN is for reading data, while Clojure's syntax is expected to be eval'ed.&lt;br&gt;
  - Tagged literals in Clojure code are treated as second-class citizens compared to built-in types because:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;1. The compiler inherently knows how to compile built-in types,
   but it does not understand other types returned by tagged
   readers.
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compiler Behavior and Challenges:&lt;/strong&gt;&lt;br&gt;
- By default:&lt;br&gt;
  - The compiler embeds the instance as a string in the emitted bytecode, recreating the instance at runtime via the reader.&lt;br&gt;
- &lt;strong&gt;Issues with Collections:&lt;/strong&gt;&lt;br&gt;
  - Container types like third party collections are problematic because their interior data is not evaluated.&lt;br&gt;
  - Common advice suggests returning a form that, when evaluated, creates an instance of the type. However:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;- This makes the result no longer a literal, as:
  - The reader does not produce the expected type.
  - Macros don't see the expected type
  - You only get the expected type after eval.
- For mixed environments (EDN without eval vs. Clojure with
  eval), separate tagged readers for the same tag may be
  required.
&lt;/code&gt;&lt;/pre&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Towards a Solution&lt;/h4&gt;
&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Compiler Extensions:&lt;/strong&gt;&lt;br&gt;
- A potential solution involves creating an extension point to teach the compiler how to compile new types.&lt;br&gt;
- Special care is required for cross-compiling dialects, such as ClojureScript.&lt;br&gt;
  - JVM collections might need to self-compile for ClojureScript.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Backward Compatibility:&lt;/strong&gt;&lt;br&gt;
- Ideally, any solution would:&lt;br&gt;
  - Retain the existing &quot;self-quoting&quot; behavior.&lt;br&gt;
  - Allow types to opt into new functionality.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14474/custom-literal-collections-reach-parity-clojures-collections</guid>
<pubDate>Thu, 20 Mar 2025 21:46:42 +0000</pubDate>
</item>
<item>
<title>Is there a polished version of auto-agents?</title>
<link>https://ask.clojure.org/index.php/14318/is-there-a-polished-version-of-auto-agents</link>
<description>&lt;p&gt;I was reading Clojure in Action and thinking about agents. It seems that by hooking up agents with watches, update functions, and some simple locks, you could create a “reactive&quot; state management. So that when some value &lt;code&gt;a&lt;/code&gt; is updated then all dependent state values update themselves automatically and in parallel on separate threads. While those values are updating you are free to change other state values that aren't in the same dependency graph&lt;/p&gt;
&lt;p&gt;I wrote up a quick draft but then started to look around online (it felt like a bit too obvious of an extension to the agent model). I found some similar ideas back in ~2009 but the trail goes dry. Is there some reason this isn't used more widely? Or is this some modern library I'm missing?&lt;/p&gt;
&lt;p&gt;There was a &quot;cell&quot; implementation by Stuart Sierra called &lt;code&gt;auto-agents&lt;/code&gt; - though I can't find the code&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://groups.google.com/g/clojure/c/NY834N34QvA&quot;&gt;https://groups.google.com/g/clojure/c/NY834N34QvA&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I also found this complete implementation but it's also got no traction at all&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/apatil/lazy-agent&quot;&gt;https://github.com/apatil/lazy-agent&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Has this crystallized into a library somewhere? I'm thinking of writing my own implementation but I wanted a sanity check. I'm concerned maybe this idea was dropped for some reasons I've not considered&lt;/p&gt;
&lt;p&gt;(I'm aware there are things like Javelin, Odoyle and Missionary that can accomplish similar things.. but while they decouple code, they're way too complicated and some don't have a threading story)&lt;/p&gt;
&lt;p&gt;This is a copy of my question on Reddit:&lt;br&gt;
&lt;a rel=&quot;nofollow&quot; href=&quot;https://reddit.com/comments/1hklfyh/comment/m3gyyoq&quot;&gt;https://reddit.com/comments/1hklfyh/comment/m3gyyoq&lt;/a&gt;&lt;/p&gt;
</description>
<category>Refs, agents, atoms</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14318/is-there-a-polished-version-of-auto-agents</guid>
<pubDate>Thu, 26 Dec 2024 18:41:21 +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>Memory leak in seque via agents</title>
<link>https://ask.clojure.org/index.php/14185/memory-leak-in-seque-via-agents</link>
<description>&lt;p&gt;We used &lt;code&gt;seque&lt;/code&gt; to manage a large database migration and observed a possible memory leak that required us to restart it several times.&lt;/p&gt;
&lt;p&gt;We iterated through hundreds of queries to extract data via reduce, each using its own &lt;code&gt;seque&lt;/code&gt; but &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/threatgrid/ctia/pull/1443#issuecomment-2404194366&quot;&gt;eventually ran out of memory&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;I believe it could have been related to &lt;code&gt;seque&lt;/code&gt; and its use of agents, which was predicted to leak memory in &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-1125&quot;&gt;CLJ-1125&lt;/a&gt;. We have not since tried a migration without &lt;code&gt;seque&lt;/code&gt; for comparison, but I instead turned my attention to &lt;code&gt;seque&lt;/code&gt; and found possibly-related problems.&lt;/p&gt;
&lt;p&gt;seque uses an agent to offer items to its buffer. Agents have a memory leak where the conveyed bindings of a &lt;code&gt;send&lt;/code&gt; are held by the executing Thread (the most relevant being &lt;code&gt;*agent*&lt;/code&gt;). This means even if the &lt;code&gt;seque&lt;/code&gt; is gc'ed, the agent persists if the thread is part of a cached thread pool, usually containing realized items from the producing seq (such as the first item to fail to be offered to the buffer).&lt;/p&gt;
&lt;p&gt;I believe this demonstrates &lt;code&gt;seque&lt;/code&gt; leaking memory (Clojure 1.12.0):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [pool-size 500]
  (defn expand-thread-pool! []
    (let [p (promise)]
      (mapv deref (mapv #(future (if (= (dec pool-size) %) (deliver p true) @p)) (range pool-size))))))

(let [_ (expand-thread-pool!) ;; increases likelihood of observing leak
      ready (promise)
      strong-ref (volatile! (Object.))
      weak-ref (java.lang.ref.WeakReference. @strong-ref)
      the-seque (volatile! (seque 1 (lazy-seq
                                      (let [s (repeat @strong-ref)]
                                        (deliver ready true)
                                        s))))]
  @ready
  (vreset! strong-ref nil)
  (vreset! the-seque nil)
  (System/gc)
  (doseq [i (range 10)
          :while (some? (.get weak-ref))]
    (prn &quot;waiting for gc...&quot;)
    (Thread/sleep 1000)
    (System/gc))
  (prn (if (nil? (.get weak-ref))
         &quot;garbage collection successful&quot;
         &quot;seque memory leak!!&quot;)))
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;seque memory leak!!&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This can be reproduced with agents. Once an agent has executed an action, a strong reference persists to the agent via &lt;code&gt;*agent*&lt;/code&gt; in the cached thread it was executed in. Here we observe the agent is not garbage collected if it has executed an action on a cached thread pool (Clojure 1.12.0):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [_ (expand-thread-pool!)
      strong-ref (volatile! (agent nil))
      weak-ref (java.lang.ref.WeakReference. @strong-ref)]
  ;#_#_ ;;uncomment this and the agent is freed
  (send-off @strong-ref vector)
  (doseq [i (range 10)
          :while (not (vector? @@strong-ref))]
    (Thread/sleep 1000))
  (vreset! strong-ref nil)
  (System/gc)
  (doseq [i (range 10)
          :while (some? (.get weak-ref))]
    (prn &quot;waiting for gc...&quot;)
    (Thread/sleep 1000)
    (System/gc))
  (prn (if (nil? (.get weak-ref))
         &quot;garbage collection successful&quot;
         &quot;agent memory leak!!&quot;)))
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;waiting for gc...&quot;
;&quot;agent memory leak!!&quot;
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Refs, agents, atoms</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14185/memory-leak-in-seque-via-agents</guid>
<pubDate>Thu, 10 Oct 2024 23:03:20 +0000</pubDate>
</item>
<item>
<title>Suggested improvements to clojure.core/distinct</title>
<link>https://ask.clojure.org/index.php/14141/suggested-improvements-to-clojure-core-distinct</link>
<description>&lt;p&gt;After looking at some performance improvements around clojure.core/distinct, I discovered that Nikita (@tonsky) had &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/2772/improve-clojure-core-distinct-perf-by-using-transient-set?show=2772#q2772&quot;&gt;made suggestions about this&lt;/a&gt; back at the end of 2016, along with a code submission at &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2090&quot;&gt;CLJ-2090&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;At the time, Alex made a comment about waiting until clojure.core/contains? supported transient sets, and the issue was pushed back. I note that this has now been addressed. However, in trying a few different approaches, I actually get better performance not using a transient at all, but instead checking if a conj has modified the object. This is done using a non-atomic deref/vreset, which begs the questions… is accessing a transducer supposed to be considered thread-safe? There are approaches to mitigate this, but there isn't a need if that's not a guarantee.&lt;/p&gt;
&lt;p&gt;I discuss some of the approaches and provide some benchmarking in &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/quoll/distinct&quot;&gt;this project on Github&lt;/a&gt;. The fastest approach actually uses the ITransientSet interface directly, which I got the impression Alex would like to avoid.&lt;/p&gt;
</description>
<category>Sequences</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14141/suggested-improvements-to-clojure-core-distinct</guid>
<pubDate>Sat, 28 Sep 2024 09:43:58 +0000</pubDate>
</item>
<item>
<title>Stack overflow with lazy-seq</title>
<link>https://ask.clojure.org/index.php/13937/stack-overflow-with-lazy-seq</link>
<description>&lt;p&gt;I'm learning Clojure by doing problems from &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/PEZ/rich4clojure&quot;&gt;rich4clojure&lt;/a&gt; repo. &lt;a rel=&quot;nofollow&quot; href=&quot;https://gist.github.com/PEZ/9dcf23444c51883c4318d69efcd5e9f7&quot;&gt;Problem 147&lt;/a&gt; asks one to create a function which returns a lazy sequence of rows following rules of Pascal triangle given initial row. For example, for [3 1 2], the next row is [3 4 3 2]. Here's my solution:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn pascal
      ([row] (lazy-seq (cons row (__ row :next))))
      ([row _]
       (lazy-seq
        (let [next-row (map #(apply +' %) (partition 2 1 (concat '(0) row '(0))))]
          (cons next-row (pascal next-row :next)))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I decided to test it and compare it with solutions others came up with. For example, one user wrote:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn pascal [coll]
(lazy-seq
  (cons coll
        (pascal (let [middle (map #(apply +' %) (partition 2 1 coll))]
                       (concat [(first coll)] middle [(last coll)]))))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I time both solutions by evaluating:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;time (nth (nth (pascal [1]) 400) 50))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and it turns out that mine is faster (which is sort of expected because the other user relies on &lt;em&gt;last&lt;/em&gt; which is O(n)). However, when I try to calculate 1000th row, I get stack overflow error only in case of my function. I'm struggling to see why this happens because I shouldn't be increasing the stack size. What am I missing?&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13937/stack-overflow-with-lazy-seq</guid>
<pubDate>Sun, 02 Jun 2024 19:14:33 +0000</pubDate>
</item>
<item>
<title>Cannot invoke &quot;clojure.lang.Var.isBound()&quot; because &quot;clojure.lang.Compiler.LOADER&quot; is null, potential bug?</title>
<link>https://ask.clojure.org/index.php/13819/cannot-clojure-isbound-because-clojure-compiler-potential</link>
<description>&lt;p&gt;As per &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1KBA2/p1713446287942589&quot;&gt;discussion&lt;/a&gt; on slack I'm posting here the findings regarding clojure.lang.Compiler.LOADER being null during the analysis phase of GraalVM native-image run.&lt;/p&gt;
&lt;p&gt;The full reproduction can be found &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/FieryCod/graalvm-repro&quot;&gt;here&lt;/a&gt; and the link to issue on Oracle GraalVM side &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/oracle/graal/issues/8801&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;What is this issue about?&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Native Image cannot be produced and throws an error during analysis phase when Clojure 1.11.2 (although the previous version of Clojure might be also affected) is used and reflection entries for java.lang.UUID and clojure.lang.Keyword are present in &lt;code&gt;reflectionconfig.json&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;I can't however reproduce the error prior to Clojure 1.9.0. For more information please kindly take a look into a repro.&lt;/p&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13819/cannot-clojure-isbound-because-clojure-compiler-potential</guid>
<pubDate>Thu, 18 Apr 2024 16:11:35 +0000</pubDate>
</item>
<item>
<title>Add `debug-assert` as a separate, off-by-default operation for expensive dev/test-only assertions</title>
<link>https://ask.clojure.org/index.php/13666/debug-assert-separate-default-operation-expensive-assertions</link>
<description>&lt;p&gt;Currently the default value for &lt;code&gt;clojure.core/*assert*&lt;/code&gt; is &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;This has some implications for library creators and consumers.&lt;/p&gt;
&lt;p&gt;As a library  creator you can't just add asserts everywhere to help you on dev/test because it will make most users pay the performance price in production, since they will be running with &lt;code&gt;*asserts*&lt;/code&gt; enable.&lt;/p&gt;
&lt;p&gt;As a library consumer, since you don't know what libraries are using asserts, you have to always remember to disable them just in case.&lt;/p&gt;
&lt;p&gt;This is worsen by the fact that is not easy to disable  them globally in Clojure, since &lt;code&gt;assert&lt;/code&gt; is a macro that checks &lt;code&gt;*assert*&lt;/code&gt;, the value of the var needs to be set before loading any namespace.&lt;/p&gt;
&lt;p&gt;On the contrary java makes all assertions disable by default, so library creators don't have to think about this, and the consumers can explicitly enable them at dev time by providing &lt;code&gt;java -ea&lt;/code&gt; (enable assertions)&lt;/p&gt;
&lt;p&gt;Since I guess changing the default value of &lt;code&gt;*assert*&lt;/code&gt; could be problematic because of backwards compatibility, it would maybe be possible to add a &lt;code&gt;debug-assert&lt;/code&gt; like is the case of Rust, which will not be on by default.&lt;/p&gt;
&lt;p&gt;As I see it, the important part is having a simple invariant checking instruction that we know is not going to impact performance by default, so hardening our code base for test and dev is not coupled to production performance in the default case.&lt;/p&gt;
&lt;p&gt;Two other options  are better default values for &lt;em&gt;assert&lt;/em&gt;, one is &lt;code&gt;false&lt;/code&gt; and the other is the value of &lt;code&gt;java.lang.Class desiredAssertionStatus()&lt;/code&gt; which seams to return true/false depending on the &lt;code&gt;-ea&lt;/code&gt; flag being provided or not, which will be also &lt;code&gt;false&lt;/code&gt; by default., but since most Clojure users already rely on &lt;em&gt;assert&lt;/em&gt; being true by default this are maybe not an option. &lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13666/debug-assert-separate-default-operation-expensive-assertions</guid>
<pubDate>Tue, 06 Feb 2024 17:42:43 +0000</pubDate>
</item>
<item>
<title>&quot;Unbound var&quot; error with reader-macro + arglists + AoT</title>
<link>https://ask.clojure.org/index.php/13610/unbound-var-error-with-reader-macro-arglists-aot</link>
<description>&lt;p&gt;Hey Alex :)&lt;/p&gt;
&lt;p&gt;Think this may be a compiler bug - necessary conditions seem to be:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Custom reader macro&lt;/li&gt;
&lt;li&gt;Used in destructuring in &lt;code&gt;defn&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;AoT compiled&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;e.g.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns foo
  (:require my.reader-macros))

(defn foo [{:keys [a], :or {a #my/reader-macro &quot;...&quot;}]
  ...)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the class file, I get:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;static {
    __init0();
    __init1();
    Compiler.pushNSandLoader(RT.classForName(&quot;foo__init&quot;).getClassLoader());

    try {
        load();
    } catch (Throwable var1) {
        Var.popThreadBindings();
        throw var1;
    }

    Var.popThreadBindings();
}
&lt;/code&gt;&lt;/pre&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;load()&lt;/code&gt; calls &lt;code&gt;new foo.loading__9166().invoke()&lt;/code&gt;, which applies the &lt;code&gt;:require&lt;/code&gt;s&lt;/li&gt;
&lt;li&gt;&lt;p&gt;but, in the &lt;code&gt;__init1()&lt;/code&gt; (in my case) it tries to create the vars, including applying the &lt;code&gt;arglists&lt;/code&gt; metadata. In applying that metadata, it has:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    RT.keyword((String)null, &quot;or&quot;), 
    RT.map(new Object[]{Symbol.intern((String)null, &quot;a&quot;), RT.readString(&quot;#my/reader-macro \&quot;...\&quot;&quot;)})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;and the &lt;code&gt;RT.readString&lt;/code&gt; call fails with 'unbound var' because &lt;code&gt;my.reader-macros&lt;/code&gt; hasn't been required yet.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Work-around is easy enough, and I daresay it's relatively rare given removing any of the three conditions above fixes the issue, but thought I'd raise nonetheless :)&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;James&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13610/unbound-var-error-with-reader-macro-arglists-aot</guid>
<pubDate>Fri, 12 Jan 2024 11:19:03 +0000</pubDate>
</item>
<item>
<title>Executable 'java' not found on system path.</title>
<link>https://ask.clojure.org/index.php/13592/executable-java-not-found-on-system-path</link>
<description>&lt;p&gt;Hi guys I,m basically trying to run a clojure script app using a shadow file, to be honest i don't really know too much about clojure since this is a project that i downloaded, but i need it to make it run locally on windows 11 and i'm receiving the following error&lt;/p&gt;
&lt;p&gt;shadow-cljs - config: C:\Appsmiths\i\src\winglue\webglue\shadow-cljs.edn&lt;br&gt;
===== ERROR =================&lt;/p&gt;
&lt;h2&gt;Executable 'java' not found on system path.&lt;/h2&gt;
&lt;p&gt;I have java on my system of course and my environment variables are well configured, so i think it could be something inside of the shadow file, but i cannot identify what it is, if you can help me out with this it would be really helpful&lt;/p&gt;
&lt;p&gt;this is basically all the shadow config:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; shadow-cljs configuration
{:dependencies [
                [akiroz.re-frame/storage &quot;0.1.3&quot;]
                [bidi &quot;2.1.5&quot;]
                [com.cemerick/url &quot;0.1.1&quot;]
                [binaryage/devtools &quot;1.0.2&quot;]
                [binaryage/oops &quot;0.7.1&quot;]
                [com.cognitect/transit-cljs &quot;0.8.256&quot;]
                [com.rpl/specter &quot;1.1.3&quot;]
                [com.taoensso/timbre &quot;4.10.0&quot;]
                [cljs-http &quot;0.1.46&quot;]
                [day8.re-frame/async-flow-fx &quot;0.1.0&quot;]
                [day8.re-frame/http-fx &quot;0.1.6&quot;]
                [day8.re-frame/re-frame-10x &quot;1.5.0&quot;]
                [day8.re-frame/tracing &quot;0.5.1&quot;]
                [day8.re-frame/undo &quot;0.3.2&quot;]
                [district0x/graphql-query &quot;1.0.6&quot;]
                [district0x/re-frame-interval-fx &quot;1.0.2&quot;]
                [expound &quot;0.8.5&quot;]
                [funcool/cuerdas &quot;2021.05.29-0&quot;]
                [funcool/promesa &quot;2.0.1&quot;]
                [juji/editscript &quot;0.4.6&quot;]
                [maximgb/re-state &quot;1.5.0&quot;]
                [medley &quot;1.2.0&quot;]
                [metosin/spec-tools &quot;0.10.4&quot;]
                [org.clojure/data.json &quot;0.2.6&quot;]
                [org.clojure/spec.alpha &quot;0.2.187&quot;]
                [pez/clerk &quot;1.0.0&quot;]
                [prismatic/schema &quot;1.1.12&quot;]
                [re-frame &quot;1.3.0&quot;]
                [re-graph &quot;0.1.15&quot; :exclusions [cljs-http]]
                [com.andrewmcveigh/cljs-time &quot;0.5.2&quot;]
                [reagent &quot;1.1.1&quot;]
                [spyscope &quot;0.1.6&quot;]
                [venantius/accountant &quot;0.2.5&quot;]
                [lambdaisland/regal &quot;0.0.143&quot;]
                [cheshire &quot;5.11.0&quot;]
                [camel-snake-kebab &quot;0.4.3&quot;]
                [garden/garden-units &quot;1.0.0-RC2&quot;]
                [cljs-bean &quot;1.8.0&quot;]]

 :source-paths [&quot;lib&quot; &quot;graphql&quot; &quot;src&quot; &quot;C:/Appsmiths/i/src/winglue-artifact/webglue&quot; &quot;test&quot;]
 :nrepl {:port 41002}
 :open-file-command [&quot;idea &quot; :pwd &quot; --line &quot; :line :file]
 ;; webglue artifact are in /i/src/winglue-artifact/webglue/js
 :builds {:app {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue/js&quot;
                :asset-path &quot;/js&quot;
                :compiler-options
                {:optimizations :none
                 ;; use es2018 for recat-markdown-editor
                 :output-feature-set :es2018
                 :main webglue.core
                 :closure-warnings {:global-this :off}
                 :closure-defines {re-frame.trace/trace-enabled? true
                                   day8.re-frame-10x.debug?             true
                                   day8.re-frame.tracing.trace-enabled? true}
                 :external-config {:devtools/config {:features-to-install    [:formatters :hints]
                                                     :fn-symbol              &quot;Fn&quot;
                                                     :print-config-overrides true}}}
                :target :browser
                :js-options {:ignore-asset-requires true}
                :module-loader true
                :modules {:webglue
                          {:entries [webglue.core]}
                          :ag-grid
                          {:entries [webglue.components.ag-grid]
                           :depends-on #{:webglue}}
                          :dev
                          {:entries [webglue.pages.component-show-case webglue.pages.dev]
                           :depends-on #{:webglue}}
                          :plot
                          {:entries [webglue.component-generator.graph
                                     webglue.component-generator.ivsp-plot
                                     webglue.component-generator.pie-chart
                                     webglue.component-generator.bar-chart
                                     webglue.component-generator.bubble-chart]
                           :depends-on #{:webglue}}}
                :devtools {:repl-pprint true
                           :after-load webglue.core/reload!
                           :loader-mode :eval
                           :http-root &quot;C:/Appsmiths/i/src/winglue-artifact/webglue&quot;
                           :http-port 3333
                           :http-handler shadow.http.push-state/handle
                           :preloads [devtools.preload
                                      ; use only for debug re-frame, this option wil take 300 ms to reload and 330 file to watch
                                      ; run by uncomment next line, and save. shadow-cljs will do the rest
                                      day8.re-frame-10x.preload]}}
          :win-app {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue&quot;
                    :asset-path &quot;/js&quot;
                    :compiler-options
                    {:optimizations :none
                     :output-feature-set :es2018
                     :main webglue.core
                     :closure-warnings {:global-this :off}
                     :closure-defines {re-frame.trace/trace-enabled? true
                                       day8.re-frame-10x.debug?             true
                                       day8.re-frame.tracing.trace-enabled? true}
                     :external-config {:devtools/config {:features-to-install    [:formatters :hints]
                                                         :fn-symbol              &quot;Fn&quot;
                                                         :print-config-overrides true}}}
                    :target :browser
                    :js-options {:ignore-asset-requires true}
                    :modules {:webglue {:entries [webglue.core]}}
                    :devtools {:http-port 3434
                               :http-root &quot;C:/Appsmiths/i/src/winglue-artifact/webglue&quot;
                               :http-handler shadow.http.push-state/handle
                               :after-load webglue.core/reload!
                               :loader-mode :eval
                               :preloads [devtools.preload
                                          day8.re-frame-10x.preload]}}
          :test {:target :browser-test
                 :test-dir &quot;test-assets&quot;
                 :devtools {:http-port 9100
                            :http-root &quot;test-assets&quot;}
                 :runner-ns main-test-initial
                 :js-options {:ignore-asset-requires true}
                 :ns-regexp &quot;-test$&quot;}

          :app-release {:target :browser
                        :modules {:webglue
                                  {:entries [webglue.core]}}
                        :js-options {:ignore-asset-requires true}
                        :compiler-options {:source-map false
                                           :output-feature-set :es2018
                                           :main  webglue.core
                                           :closure-defines {}}
                        :release  {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue/js&quot;}}

          :tao2py-release {:target :browser
                           :js-options {:ignore-asset-requires true}
                           :compiler-options
                           {:source-map false
                            :output-feature-set :es2018
                            :main  webglue.core
                            :closure-defines {webglue.config/tao2py-release true
                                              ;; landing page is page key in webglue.route_pages
                                              webglue.config/landing-page &quot;field-overview&quot;}}
                           :release  {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue/js&quot;
                                      :asset-path &quot;/js&quot;}
                           :module-loader true
                           :modules {:webglue
                                     {:entries [webglue.core]}
                                     :ag-grid
                                     {:entries [webglue.components.ag-grid]
                                      :depends-on #{:webglue}}
                                     :dev
                                     {:entries [webglue.pages.component-show-case webglue.pages.dev]
                                      :depends-on #{:webglue}}
                                     :plot
                                     {:entries [webglue.component-generator.graph
                                                webglue.component-generator.ivsp-plot
                                                webglue.component-generator.pie-chart
                                                webglue.component-generator.bar-chart
                                                webglue.component-generator.bubble-chart]
                                      :depends-on #{:webglue}}}}

          :tao2py-testing {:target :browser
                           :modules {:webglue
                                     {:entries [webglue.core]}}
                           :js-options {:ignore-asset-requires true}
                           :compiler-options {:source-map false
                                              :output-feature-set :es2018
                                              :main  webglue.core
                                              :closure-defines {}}
                           :release  {:output-dir &quot;C:/Appsmiths/i/src/winglue-artifact/webglue/js&quot;}}

          :budger-release {:target :browser
                           :modules {:webglue {:entries [webglue.core]}}
                           :release {:output-dir &quot;release/js&quot;}
                           :js-options {:ignore-asset-requires true}
                           :compiler-options {:source-map false
                                              :output-feature-set :es2018
                                              :main       webglue.core
                                              :closure-defines {}}}}}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Compiler</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13592/executable-java-not-found-on-system-path</guid>
<pubDate>Wed, 03 Jan 2024 19:38:51 +0000</pubDate>
</item>
<item>
<title>Hypergraphs, via protocols, perhaps extending loom?</title>
<link>https://ask.clojure.org/index.php/13444/hypergraphs-via-protocols-perhaps-extending-loom</link>
<description>&lt;p&gt;I am exploring clojure implementations of hypergraphs (edges can join &amp;gt; 2 nodes)?  i've used &lt;a rel=&quot;nofollow&quot; href=&quot;https://cljdoc.org/d/aysylu/loom&quot;&gt;loom&lt;/a&gt;  for graphs, and imagine trying to extend it somehow.  &lt;/p&gt;
&lt;p&gt;either with loom or without, any suggestions how to use PROTOCOLS for these definitions?&lt;/p&gt;
&lt;p&gt;thanks for any suggestions.  - RIk&lt;/p&gt;
</description>
<category>Protocols</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13444/hypergraphs-via-protocols-perhaps-extending-loom</guid>
<pubDate>Thu, 09 Nov 2023 02:41:39 +0000</pubDate>
</item>
<item>
<title>print-method is inconsistent with regard to clojure.pprint with *print-level*</title>
<link>https://ask.clojure.org/index.php/13337/print-method-inconsistent-regard-clojure-pprint-print-level</link>
<description>&lt;p&gt;Repro:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; print-method

user=&amp;gt; (binding [*print-level* 1]
         (prn {:a 1 :b 2}))
{:a 1, :b 2}
nil

user=&amp;gt; (binding [*print-level* 1]
         (prn {:a {:b 2}}))
{:a #}
nil

user=&amp;gt; (binding [*print-level* 1]
         (prn [(clojure.lang.MapEntry. :a 1)
               (clojure.lang.MapEntry. :b 2)]))
[# #]
nil

;; clojure.pprint

user=&amp;gt; (binding [*print-level* 1]
         (clojure.pprint/pprint {:a 1 :b 2}))
{#, #}
nil

user=&amp;gt; (binding [*print-level* 1]
         (clojure.pprint/pprint {:a {:b 2}}))
{#}
nil

user=&amp;gt; (binding [*print-level* 1]
         (clojure.pprint/pprint
           [(clojure.lang.MapEntry. :a 1)
            (clojure.lang.MapEntry. :b 1)]))
[# #]
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The docstring for &lt;code&gt;*print-level*&lt;/code&gt; says:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;If an object is a collection and is at a level greater than or equal to the value bound to &lt;em&gt;print-level&lt;/em&gt;, the printer prints '#' to represent it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A map entry is a collection and in &lt;code&gt;{:a 1, :b 2}&lt;/code&gt; is at a level equal to &lt;code&gt;*print-level*&lt;/code&gt;, so I would expect &lt;code&gt;prn&lt;/code&gt; to have the same output as &lt;code&gt;clojure.pprint&lt;/code&gt;.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13337/print-method-inconsistent-regard-clojure-pprint-print-level</guid>
<pubDate>Thu, 28 Sep 2023 07:02:04 +0000</pubDate>
</item>
<item>
<title>How to design testing library?</title>
<link>https://ask.clojure.org/index.php/13296/how-to-design-testing-library</link>
<description>&lt;p&gt;I would like to create a sort of testing library or framework. The main purpose of it is to run UI tests on Android device. For example, here is example of how I would like it look like:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(test-flow
    (launch-app &quot;some.app.id&quot;)
    (assert-visible &quot;Login&quot;)
    (type-text &quot;admin&quot;)
    (tap-on &quot;unlockButton&quot;)
    (assert-visible &quot;HomeScreen&quot;))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I hope this API looks nice and clear. Basically here is what it is supposed to do:&lt;br&gt;
- launch application with id &quot;some.app.id&quot;&lt;br&gt;
- check that login field with name &quot;Login&quot; is visible on the screen&lt;br&gt;
- type a text &quot;admin&quot; (into login field)&lt;br&gt;
- tap on unlock button&lt;br&gt;
- check that text &quot;HomeScreen&quot; is visible, what means we successfully logged in.&lt;/p&gt;
&lt;p&gt;I've already created all the desired functions above and that was easy part. I've designed them so they return a hash-map that may have either &lt;code&gt;:result&lt;/code&gt; or &lt;code&gt;:error&lt;/code&gt;. But I've been stuck on how to use those functions together, so it will work as a testing framework. If I put them inside some function and if some of the steps fails, then execution will just continue to the next step. Moreover, the result of a failed step will be lost. After that I decided to write a macros, that will transform all functions into list, evaluate them one by one and return detailed result for each step. But I failed to do that (event with the help of ChatGPT), maybe because I'm noob in Clojure.&lt;/p&gt;
&lt;p&gt;After probably a week of inability to solve this problem, I think maybe I'm doing something wrong. Maybe someone could help me with that API problem?&lt;/p&gt;
&lt;p&gt;Here is my vision of that API:&lt;br&gt;
- the result of the test should have results from all executed steps (functions)&lt;br&gt;
- if one step fails, then execution should be stopped, and results for all executed steps should be returned.&lt;/p&gt;
&lt;p&gt;I was inspired by this &lt;a rel=&quot;nofollow&quot; href=&quot;https://maestro.mobile.dev/&quot;&gt;framework&lt;/a&gt;, I just think it would be much easier to write such tests with REPL and do some Clojure magic inside the test :) &lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13296/how-to-design-testing-library</guid>
<pubDate>Fri, 15 Sep 2023 20:47:59 +0000</pubDate>
</item>
<item>
<title>Links to EPL license are now broken</title>
<link>https://ask.clojure.org/index.php/13193/links-to-epl-license-are-now-broken</link>
<description>&lt;p&gt;Links such as &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/2a058814e5fa3e8fb630ae507c3fa7dc865138c6/test/clojure/test_clojure/protocols.clj#L3C33-L3C79&quot;&gt;https://github.com/clojure/clojure/blob/2a058814e5fa3e8fb630ae507c3fa7dc865138c6/test/clojure/test_clojure/protocols.clj#L3C33-L3C79&lt;/a&gt; direct one to a 404 page.&lt;/p&gt;
</description>
<category>Docs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13193/links-to-epl-license-are-now-broken</guid>
<pubDate>Wed, 23 Aug 2023 17:16:20 +0000</pubDate>
</item>
<item>
<title>problem with Null exception in cl-format</title>
<link>https://ask.clojure.org/index.php/13162/problem-with-null-exception-in-cl-format</link>
<description>&lt;p&gt;If the format string ends in ~@, there is code in cl-format to detect this&lt;br&gt;
and issue a format-error.  However, that error detection is wrong, and a null exception&lt;br&gt;
happens rather than the format-error being reported.&lt;/p&gt;
&lt;p&gt;To reproduce this, simply evaluate the following.&lt;/p&gt;
&lt;p&gt;clojure.pprint&amp;gt; (cl-format false &quot;~@&quot;)&lt;br&gt;
Execution error (NullPointerException) at nrepl.middleware.interruptible-eval/evaluate$fn$fn (interruptible_eval.clj:87).&lt;/p&gt;
&lt;p&gt;I have a fix for this which I'd like to contribute.&lt;/p&gt;
&lt;p&gt;Here is the new version of the code &lt;code&gt;compile-directive&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn- compile-directive [s offset]
  (let [[raw-params [rest offset]] (extract-params s offset)
        [_ [rest offset flags]] (extract-flags rest offset)
        directive (first rest)
        ;; previous version was missing (if directive ...) here thus (format-error ...) never reached
        def (if directive (get directive-table (Character/toUpperCase ^Character directive)))
        params (if def (map-params def (map translate-param raw-params) flags offset))]
    (if (not directive)
      (format-error &quot;Format string ended in the middle of a directive&quot; offset))
    (if (not def)
      (format-error (str &quot;Directive \&quot;&quot; directive &quot;\&quot; is undefined&quot;) offset))
    [(struct compiled-directive ((:generator-fn def) params offset) def params offset)
     (let [remainder (subs rest 1) 
           offset (inc offset)
           trim? (and (= \newline (:directive def))
                      (not (:colon params)))
           trim-count (if trim? (prefix-count remainder [\space \tab]) 0)
           remainder (subs remainder trim-count)
           offset (+ offset trim-count)]
       [remainder offset])]))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The old version&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13162/problem-with-null-exception-in-cl-format</guid>
<pubDate>Wed, 16 Aug 2023 14:36:19 +0000</pubDate>
</item>
<item>
<title>Channel for real-time conversation on Freenode irc, visit: https://webchat.freenode.net/</title>
<link>https://ask.clojure.org/index.php/13133/channel-conversation-freenode-visit-https-webchat-freenode</link>
<description>&lt;p&gt;visit: &lt;a rel=&quot;nofollow&quot; href=&quot;https://webchat.freenode.net/&quot;&gt;https://webchat.freenode.net/&lt;/a&gt;&lt;br&gt;
in channel, type: #clojure&lt;br&gt;
remember that this channel of ours is there for everyone to clear up doubts, talk but above all maintain respect for the next person.&lt;br&gt;
Enjoy it!&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13133/channel-conversation-freenode-visit-https-webchat-freenode</guid>
<pubDate>Fri, 04 Aug 2023 14:56:52 +0000</pubDate>
</item>
<item>
<title>Locals clearing issue with a type-hinted vs non-type-hinted letfn?</title>
<link>https://ask.clojure.org/index.php/13019/locals-clearing-issue-with-type-hinted-non-type-hinted-letfn</link>
<description>&lt;p&gt;Hey folks - I seem to be getting a locals clearing issue with a type-hinted vs non-type-hinted &lt;code&gt;letfn&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn- letfn-prim []
  (letfn [(f [coll ^long n]
            )]
    (f (take 3 (range)) 0)))

(defn- letfn-noprim []
  (letfn [(f [coll n]
            )]
    (f (take 3 (range)) 0)))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(in practice, I'm lazily processing coll within &lt;code&gt;f&lt;/code&gt; and wanted to avoid retaining the head)&lt;/p&gt;
&lt;p&gt;The noprim variant clears the coll param correctly; the prim version doesn't seem to.&lt;/p&gt;
&lt;p&gt;(I'm aware &lt;code&gt;letfn&lt;/code&gt; doesn't fully support type-hints, but this one seems to be more than just an unexpected boxing, and affects more than just the hinted variable)&lt;/p&gt;
&lt;p&gt;In both cases, the caller is calling &lt;code&gt;f.invoke(Object)&lt;/code&gt; (&lt;code&gt;invokeinterface clojure/lang/IFn.invoke:(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;&lt;/code&gt;), but the difference comes in the &lt;code&gt;f&lt;/code&gt; function. (Arguably the hinted version could call &lt;code&gt;invokePrim&lt;/code&gt; directly, but as I say, aware &lt;code&gt;letfn&lt;/code&gt; doesn't fully support type-hints)&lt;/p&gt;
&lt;p&gt;In the unhinted case, &lt;code&gt;invoke&lt;/code&gt; is trivial:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aconst_null
       1: areturn
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(adding more of a body clears the param as soon as it can)&lt;/p&gt;
&lt;p&gt;but in the hinted case, we get this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  public final java.lang.Object invokePrim(java.lang.Object, long);
    Code:
       0: aconst_null
       1: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_0
       1: aload_1
       2: aload_2
       3: checkcast     #22                 // class java/lang/Number
       6: invokestatic  #28                 // Method clojure/lang/RT.longCast:(Ljava/lang/Object;)J
       9: invokeinterface #30,  4           // InterfaceMethod clojure/lang/IFn$OLO.invokePrim:(Ljava/lang/Object;J)Ljava/lang/Object;
      14: areturn
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The &lt;code&gt;invoke&lt;/code&gt; calls through to &lt;code&gt;invokePrim&lt;/code&gt; as normal, but it doesn't clear its locals before doing so. compare to&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn- defn-prim [coll ^long n]
  )
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;whose bytecode does clear the object in its invoke method:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  public static java.lang.Object invokeStatic(java.lang.Object, long);
    Code:
       0: aconst_null
       1: areturn

  public java.lang.Object invoke(java.lang.Object, java.lang.Object);
    Code:
       0: aload_1
       1: aconst_null
       2: astore_1      // &amp;lt;--- local cleared here
       3: aload_2
       4: checkcast     #21                 // class java/lang/Number
       7: invokestatic  #27                 // Method clojure/lang/RT.longCast:(Ljava/lang/Object;)J
      10: invokestatic  #29                 // Method invokeStatic:(Ljava/lang/Object;J)Ljava/lang/Object;
      13: areturn

  public final java.lang.Object invokePrim(java.lang.Object, long);
    Code:
       0: aload_1
       1: aconst_null
       2: astore_1
       3: lload_2
       4: invokestatic  #29                 // Method invokeStatic:(Ljava/lang/Object;J)Ljava/lang/Object;
       7: areturn
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Cheers!&lt;/p&gt;
&lt;p&gt;James&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13019/locals-clearing-issue-with-type-hinted-non-type-hinted-letfn</guid>
<pubDate>Fri, 16 Jun 2023 16:19:58 +0000</pubDate>
</item>
<item>
<title>Performance improvements to creation of small vectors with TransientVector</title>
<link>https://ask.clojure.org/index.php/13009/performance-improvements-creation-vectors-transientvector</link>
<description>&lt;p&gt;Sorry for doing it backward and submitting the ticket /patch first. The ticket is here: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/jira/software/c/projects/CLJ/issues/CLJ-2786&quot;&gt;https://clojure.atlassian.net/jira/software/c/projects/CLJ/issues/CLJ-2786&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The ticket contains all the important details, benchmarking results, and code. Here I would like to hear whether people generally use transients, how they decide if transients will lead to performance improvement rather than degradation, and any other possible doubts. I always had mixed feelings when doing something through transients, probably due to a section in Joy of Clojure claiming that transients are inefficient for small inputs. The benchmark done with the current version of Clojure overall confirms that.&lt;/p&gt;
</description>
<category>Sequences</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13009/performance-improvements-creation-vectors-transientvector</guid>
<pubDate>Tue, 13 Jun 2023 12:52:56 +0000</pubDate>
</item>
<item>
<title>Run a task parallely to delete tags</title>
<link>https://ask.clojure.org/index.php/12999/run-a-task-parallely-to-delete-tags</link>
<description>&lt;pre&gt;&lt;code&gt;(defn- find-story-ids-by-tag [tag-id]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;  (map :id (db-content-tag/read-contents-by-tag-id (config/db-spec) tag-id)))&lt;/p&gt;
&lt;p&gt;(defn- update-story [txn publisher-id story-id tag-id]&lt;br&gt;
  (let [{:keys [published-json]} (db-content/find-by-id txn story-id)&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;    updated-tags (filter (fn [tag] (not= (:id tag) tag-id)) (:tags published-json))
    _ (db-story/update-published-json-without-timestamps txn publisher-id story-id (assoc published-json :tags updated-tags))]
(log/info {:message &quot;[TAG-DELETION] Updated Story Tags in Published JSON&quot;
           :publisher-id publisher-id
           :tag-id tag-id
           :story-id story-id
           :updated-tags-json updated-tags})))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(defn- delete-tag [publisher-id tag-id]&lt;br&gt;
  (let [associated-content-ids (find-story-ids-by-tag tag-id)]&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(transaction/with-transaction
  [txn (config/db-spec)]
  (do
    (when (seq associated-content-ids)
      (do
        (doseq [story-id associated-content-ids]
          (update-story txn publisher-id story-id tag-id))
        (db-content-tag/delete-batch-by-tag txn tag-id associated-content-ids)
        (log/info {:message &quot;[TAG-DELETION] Deleted from Content Tag&quot;
                   :publisher-id publisher-id
                   :tag-id tag-id
                   :story-ids associated-content-ids})))
    (db-tag/delete txn publisher-id tag-id)
    (log/info {:message &quot;[TAG-DELETION] Deleted Tag&quot;
               :publisher-id publisher-id
               :tag-id tag-id})))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(defn run [publisher-id tag-ids]&lt;br&gt;
  (comment run 123 [4 5 6])&lt;br&gt;
  (try&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(do
  (log/info {:message &quot;[TAG-DELETION] started&quot;
             :publisher-id publisher-id
             :tag-ids tag-ids})
  (doseq [tag-id tag-ids] (if (db-tag/find-by-id (config/db-spec) publisher-id tag-id)
                            (delete-tag publisher-id tag-id)
                            (log/info {:message &quot;[TAG-DELETION] Tag Not Found&quot;
                                       :publisher-id publisher-id
                                       :tag-id tag-id})))
  (log/info {:message &quot;[TAG-DELETION] completed&quot;
             :publisher-id publisher-id
             :tag-ids tag-ids}))
(catch Exception e
  (log/exception e {:message &quot;[TAG-DELETION] errored&quot;
                    :publisher-id publisher-id
                    :tag-ids tag-ids}))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I have less than 100 tags this works, but say I have 100 000 tags it is very time consuming. How to modify this code which can run in parallel and takes less time? Currently the task uses seq for both deleting and updating the story&lt;/p&gt;
</description>
<category>Sequences</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12999/run-a-task-parallely-to-delete-tags</guid>
<pubDate>Sun, 04 Jun 2023 23:21:53 +0000</pubDate>
</item>
<item>
<title>how to start a web server in dev mode in an interactive mode with hot reload and refresh</title>
<link>https://ask.clojure.org/index.php/12933/start-server-mode-interactive-mode-with-reload-and-refresh</link>
<description>&lt;p&gt;Hello wonderful clojure community.&lt;br&gt;
I am new to clojure so appologies for my dump question.&lt;/p&gt;
&lt;p&gt;I want to write a http server in clojure and for that there a a few libraries/frameworks available. but what is important for me is the interactive development experience, how?&lt;/p&gt;
&lt;p&gt;ok, I want to start the server and if I change a module/namespace I want it to be automatically reload (actually I've already achieved this) however on top of it I want the frontend to get refreshed automatically to to refelect the changes. I use hiccup to describe/render my html pages, unfortunately though for any change I need to manually refresh the page.&lt;/p&gt;
&lt;p&gt;I know there should be a (websocket based) solution to make this possible.&lt;/p&gt;
&lt;p&gt;I want this soution to work with clojure, I do not use/want clojurescrip.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12933/start-server-mode-interactive-mode-with-reload-and-refresh</guid>
<pubDate>Fri, 12 May 2023 08:20:46 +0000</pubDate>
</item>
<item>
<title>Syntax of sql files for luminus-migrations</title>
<link>https://ask.clojure.org/index.php/11951/syntax-of-sql-files-for-luminus-migrations</link>
<description>&lt;p&gt;Can the luminus-migration library be used with normal MySQL/MariaDB SQL backup files to migrate a database, or is the syntax different? &lt;/p&gt;
&lt;p&gt;Background: I'm trying to create and populate the tables of a MariaDB database with SQL scripts stored in the resources/migrations subdirectory. For this I use a project that was created with the Leiningen template luminus. The project uses the luminus-migration library for migration. If I load the SQL script directly (with a mysql client) into the database, the table is created and the data is imported. On the other hand, if I use the command 'lein run migrate', nothing happens.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11951/syntax-of-sql-files-for-luminus-migrations</guid>
<pubDate>Mon, 06 Jun 2022 21:32:59 +0000</pubDate>
</item>
<item>
<title>Clojure and Clojurescript as options for an Electronic Health Record project</title>
<link>https://ask.clojure.org/index.php/11595/clojure-clojurescript-options-electronic-health-project</link>
<description>&lt;p&gt;I am the founder of a company that is building a next-generation Electronic Health Record system. The software will have both web and mobile UIs and make heavy use of bleeding-edge Natural Language Understanding and Artificial Intelligence.&lt;/p&gt;
&lt;p&gt;I am exploring programming language options and am very interested in Clojure because of its functional language paradigm, robust support for concurrency, and reputation for high expressivity, among other things.&lt;/p&gt;
&lt;p&gt;I am seeking input about the major pros and cons for this kind of project.&lt;/p&gt;
&lt;p&gt;My company website is &lt;a rel=&quot;nofollow&quot; href=&quot;https://mpathysoftware.com/&quot;&gt;https://mpathysoftware.com/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Thank you!&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11595/clojure-clojurescript-options-electronic-health-project</guid>
<pubDate>Sat, 19 Feb 2022 16:09:36 +0000</pubDate>
</item>
<item>
<title>Protocol dispatch via interfaces is nondeterministic</title>
<link>https://ask.clojure.org/index.php/11075/protocol-dispatch-via-interfaces-is-nondeterministic</link>
<description>&lt;p&gt;If an object is an instance of multiple (unrelated) interfaces that each extend a protocol, the dispatched method will be chosen at random.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn reproduce []
  (eval 
    (list 'do
          (list 'ns (gensym))
          '(do (definterface A)
               (definterface B)

               (defprotocol P
                 (a [this]))

               (extend-protocol P
                 A
                 (a [this] :a)
                 B
                 (a [this] :b))
               (a (reify A B))))))

(frequencies
  (repeatedly 100 reproduce))
;=&amp;gt; {:b 52, :a 48}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;One solution is to sort interfaces by name before choosing the implementation, so at least the nondeterminism is eliminated. We could go further and also print a warning in this case.&lt;/p&gt;
&lt;p&gt;Logged as: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2656&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2656&lt;/a&gt;&lt;/p&gt;
</description>
<category>Protocols</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11075/protocol-dispatch-via-interfaces-is-nondeterministic</guid>
<pubDate>Tue, 21 Sep 2021 19:25:07 +0000</pubDate>
</item>
<item>
<title>(s/form (s/multi-spec ...)) returns a list with non-symbolic objects</title>
<link>https://ask.clojure.org/index.php/10969/s-form-s-multi-spec-returns-a-list-with-non-symbolic-objects</link>
<description>&lt;p&gt;My understanding is that &lt;code&gt;s/form&lt;/code&gt; is expected to return symbolic lists that can be passed to &lt;code&gt;eval&lt;/code&gt;. Forms of multi-spec specs don't behave that way, returning retag as evaluated value (e.g. a function instance).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn retag [x v]
  (assoc (vec x) 0 v))

(defmulti command first)

(s/form (s/multi-spec command retag))
=&amp;gt; (clojure.spec.alpha/multi-spec 
    current.ns/command
    #object[current.ns$retag 0x708d0436 current.ns$retag@708d0436])

;; should be something like
=&amp;gt; (clojure.spec.alpha/multi-spec 
    current.ns/command 
    current.ns/retag)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Spec</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10969/s-form-s-multi-spec-returns-a-list-with-non-symbolic-objects</guid>
<pubDate>Tue, 24 Aug 2021 11:08:11 +0000</pubDate>
</item>
<item>
<title>Could we expose the data behind ranges?</title>
<link>https://ask.clojure.org/index.php/10758/could-we-expose-the-data-behind-ranges</link>
<description>&lt;p&gt;dtype-next, libpython-clj, and tech.ml.dataset all assign special meaning to ranges but they often have to deconstruct them to do so.  For libpython, we create actual python ranges in some cases.  For dtype-next and friends, a range with increment of 1 may indicate a sub-buffer operation as opposed to an indexed-buffer operation -- sub-buffer retains the ability for System/arraycopy and the like to work correctly and is thus a major optimization in some cases.  &lt;/p&gt;
&lt;p&gt; I would like to be able to get the start, step, and end (when it exists) from any object created via &lt;code&gt;clojure.core/range&lt;/code&gt;.  I can currently do this via reflection or via subtraction of the first and second members of the sequence generated via the range along with count but I think it may be a safe and reasonable change to be able to query this information directly.&lt;/p&gt;
&lt;p&gt;Most of this could be achieved by simply making the members start, step, and end members of LongRange and Range public as they are &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/jvm/clojure/lang/LongRange.java#L27&quot;&gt;already final&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;As a separate discussion it may be worth considering having finite ranges work like persistent vectors.  I don't want to confuse the above point with this one but it sometimes more efficient to index into ranges via nth or an IFn invoke pathway than it is to use Clojure's sequence abstraction.  Finite ranges are logically to me more like persistent vectors in nature and potentially they could behave precisely like persistent vectors including w/r/t hashcode, deriving from &lt;code&gt;java.util.RandomAccess&lt;/code&gt;, and having conj produce either a new range or a persistent vector depending on if the value fits properly in the sequence.&lt;/p&gt;
</description>
<category>Collections</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10758/could-we-expose-the-data-behind-ranges</guid>
<pubDate>Sat, 10 Jul 2021 12:45:09 +0000</pubDate>
</item>
<item>
<title>Unable to run Clara Rules from Java</title>
<link>https://ask.clojure.org/index.php/10662/unable-to-run-clara-rules-from-java</link>
<description>&lt;p&gt;Im beginning to learn Clara Rules and wanted to execute them from Java. I'm getting an error when trying to run the code. &lt;code&gt;ExceptionInInitializerError: Syntax error compiling at (example/shopping.clj:2:3). clara.rules.accumulators&lt;/code&gt;. I'm attaching the project source for your reference. Could you please help. Please install Maven. Go to your project root directory and to compile the project execute &lt;code&gt;mvn -q compile&lt;/code&gt; To run the code &lt;code&gt;mvn -q exec:java -Dexec.mainClass=example.ClaraExampleMain&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://drive.google.com/drive/folders/1axsfs9mP1Uv2Q3qyZPHWMeZdJdmRwox5?usp=sharing&quot;&gt;SourceCode to the project&lt;/a&gt;&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10662/unable-to-run-clara-rules-from-java</guid>
<pubDate>Sat, 29 May 2021 12:17:53 +0000</pubDate>
</item>
<item>
<title>Should clojure.zip preserve metadata on zipper that is in end state?</title>
<link>https://ask.clojure.org/index.php/10586/should-clojure-zip-preserve-metadata-zipper-that-end-state</link>
<description>&lt;p&gt;It can be useful to attach arbitrary metadata to a zipper.&lt;/p&gt;
&lt;p&gt;When doing so, this metadata is preserved, as far as I can tell, by all zipper operation that return a zipper, except when the end state is reached.&lt;/p&gt;
&lt;p&gt;I studied the behaviour with the following code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(def res
  (let [zloc (vary-meta (czip/vector-zip [1 2 3])
                        assoc :my-app/my-thing 42)
        ops [[&quot;down&quot; czip/down]
             [&quot;up&quot; czip/up]
             [&quot;down&quot; czip/down]
             [&quot;right&quot; czip/right]
             [&quot;left&quot; czip/left]
             [&quot;rightmost&quot; czip/rightmost]
             [&quot;leftmost&quot; czip/leftmost]
             [&quot;next&quot; czip/next]
             [&quot;prev&quot; czip/prev]
             [&quot;up&quot; czip/up]
             [&quot;append-child&quot; #(czip/append-child % &quot;append-child&quot;)]
             [&quot;down&quot; czip/down]
             [&quot;edit&quot; #(czip/edit % str &quot;-edit&quot;)]
             [&quot;up&quot; czip/up]
             [&quot;insert-child&quot; #(czip/insert-child % &quot;insert-child&quot;)]
             [&quot;down&quot; czip/down]
             [&quot;right&quot; czip/right]
             [&quot;insert-left&quot; #(czip/insert-left % &quot;insert-left&quot;)]
             [&quot;insert-right&quot; #(czip/insert-right % &quot;insert-right&quot;)]
             [&quot;rightmost&quot; czip/rightmost]
             [&quot;remove&quot; czip/remove]
             [&quot;replace&quot; #(czip/replace % &quot;replace&quot;)]
             [&quot;rightmost&quot; czip/rightmost]
             [&quot;next past last node&quot; czip/next]]]
    (-&amp;gt;&amp;gt; (reductions (fn [zloc [_desc f]] (f zloc))
                     zloc
                     ops)
         (map vector (into [[&quot;--&quot; &quot;--&quot;]] ops))
         (map (fn [[[desc _f] zloc]]
                {:op-desc desc
                 :end? (czip/end? zloc)
                 :node (czip/node zloc)
                 :root (czip/root zloc)
                 :my-meta (some-&amp;gt; zloc meta :my-app/my-thing)
                 :meta (meta zloc)})))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;If I then search the result:   &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(filter #(or (:end %)
             (nil? (:my-meta %))
             (nil? (:meta %)))
        res)
;; =&amp;gt; ({:op-desc &quot;next past last node&quot;,
;;      :end? true,
;;      :node [&quot;insert-child&quot; &quot;insert-left&quot; &quot;1-edit&quot; &quot;insert-right&quot; 2 &quot;replace&quot;],
;;      :root [&quot;insert-child&quot; &quot;insert-left&quot; &quot;1-edit&quot; &quot;insert-right&quot; 2 &quot;replace&quot;],
;;      :my-meta nil,
;;      :meta nil})
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, it looks like all operations preserve my arbitrary metadata except when the returned zipper is in an end state.&lt;/p&gt;
&lt;p&gt;There's no value to dumping the full results from above, but let's look at an arbitrary single result, just to show what things look like when we are not in the zipper end state:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(nth res 11)
;; =&amp;gt; {:op-desc &quot;append-child&quot;,
;;     :end? false,
;;     :node [1 2 3 &quot;append-child&quot;],
;;     :root [1 2 3 &quot;append-child&quot;],
;;     :my-meta 42,
;;     :meta
;;     {:zip/branch? #function[clojure.core/vector?--5431],
;;      :zip/children #function[clojure.core/seq--5419],
;;      :zip/make-node #function[clojure.zip/vector-zip/fn--9351],
;;      :my-app/my-thing 42}}
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10586/should-clojure-zip-preserve-metadata-zipper-that-end-state</guid>
<pubDate>Tue, 11 May 2021 20:10:42 +0000</pubDate>
</item>
<item>
<title>Fails to load gen-classed class with pf4j from uberjar</title>
<link>https://ask.clojure.org/index.php/10093/fails-to-load-gen-classed-class-with-pf4j-from-uberjar</link>
<description>&lt;p&gt;The problem here might be more related to the pf4j default classloader but still:&lt;/p&gt;
&lt;p&gt;I have a clojure plugin generating a class &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(gen-class
 :name myplugin.SomeExtension
 :implements [plugin.SomeExtensionPoint]
 :prefix &quot;-&quot;
 :impl-ns my-plugin.some-extension)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The plugin jar  is loaded in my clojure application using pf4j. When it is compiled with &lt;code&gt;lein jar&lt;/code&gt; the class loads (but then I naturally have to put any plugin dependencies in the apps &lt;code&gt;project.clj&lt;/code&gt;). When compiled with &lt;code&gt;lein uberjar&lt;/code&gt; it fails with:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt; Execution error (IllegalStateException) at myplugin.SomeExtension/&amp;lt;clinit&amp;gt; (REPL:-1).
; Attempting to call unbound fn: #'clojure.core/refer
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;with top of call stack&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;jdk.internal.reflect.NativeConstructorAccessorImpl/newInstance0 (NativeConstructorAccessorImpl.java:-2)
jdk.internal.reflect.NativeConstructorAccessorImpl/newInstance (NativeConstructorAccessorImpl.java:62)
jdk.internal.reflect.DelegatingConstructorAccessorImpl/newInstance (DelegatingConstructorAccessorImpl.java:45)
java.lang.reflect.Constructor/newInstance (Constructor.java:490)
java.lang.Class/newInstance (Class.java:584)
org.pf4j.DefaultExtensionFactory/create (DefaultExtensionFactory.java:38)
org.pf4j.ExtensionWrapper/getExtension (ExtensionWrapper.java:37)
org.pf4j.AbstractPluginManager/getExtensions (AbstractPluginManager.java:971)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I've struggled a bit but I am unsure about exactly what happens here and how to solve it?&lt;br&gt;
Any ideas are most welcome!&lt;/p&gt;
&lt;p&gt;(and the uberjar profile uses &lt;code&gt;{:aot :all :omit-source true}&lt;/code&gt;)&lt;/p&gt;
</description>
<category>Java Interop</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10093/fails-to-load-gen-classed-class-with-pf4j-from-uberjar</guid>
<pubDate>Tue, 26 Jan 2021 16:23:57 +0000</pubDate>
</item>
<item>
<title>Hide Warnings from Com.Google.Cloud.Translate</title>
<link>https://ask.clojure.org/index.php/10092/hide-warnings-from-com-google-cloud-translate</link>
<description>&lt;p&gt;Howdy.  I am using this excellent wrapper over google translate. &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/billwinkler/google-translate&quot;&gt;https://github.com/billwinkler/google-translate&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;However, whenever I invoke &lt;br&gt;
&lt;code&gt;(gt/translate!  ... :from &quot;&quot; :to &quot;&quot;)&lt;/code&gt; &lt;br&gt;
I get warnings printed to the console / REPL.&lt;br&gt;
I would really like to not see these warnings:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;WARNING: Ignoring Application Default Credentials GOOGLE_APPLICATION_CREDENTIALS: using explicit setting for API key instead.&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I am relatively new to logging and understand the java side of things is a mess, is there any way I can prevent seeing these warnings in the REPL ?&lt;/p&gt;
</description>
<category>REPL</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10092/hide-warnings-from-com-google-cloud-translate</guid>
<pubDate>Tue, 26 Jan 2021 02:38:21 +0000</pubDate>
</item>
<item>
<title>-X args: pass in entire map + merge strategy</title>
<link>https://ask.clojure.org/index.php/10060/x-args-pass-in-entire-map-merge-strategy</link>
<description>&lt;p&gt;I would like to pass in an entire arg map to &lt;code&gt;clojure -X&lt;/code&gt; and decide using a custom function how this should be merged with the default one from deps.edn. This could be a function in the &lt;code&gt;:exec-fn&lt;/code&gt; alias, e.g. &lt;code&gt;:exec-merge-args&lt;/code&gt; (and could default to &lt;code&gt;merge&lt;/code&gt; or something based on &lt;code&gt;merge-with&lt;/code&gt;).  &lt;/p&gt;
&lt;p&gt;My reason for this request is that passing in individual paths takes quite a lot of quoting on the command line for paths and strings. It would be less thinking and less error prone to just pass in one quoted map.&lt;/p&gt;
&lt;p&gt;This is related to &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/10059/x-args-add-things-to-vector&quot;&gt;https://ask.clojure.org/index.php/10059/x-args-add-things-to-vector&lt;/a&gt;.&lt;br&gt;
If I could describe how this should be merged using a custom function, adding things to a vector would be sufficiently solved as well.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10060/x-args-pass-in-entire-map-merge-strategy</guid>
<pubDate>Fri, 15 Jan 2021 14:17:39 +0000</pubDate>
</item>
<item>
<title>-X args: add things to vector</title>
<link>https://ask.clojure.org/index.php/10059/x-args-add-things-to-vector</link>
<description>&lt;p&gt;How does one update an arg map for &lt;code&gt;clojure -X&lt;/code&gt; like in the following:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;{:some-tool {:scan-paths [&quot;src&quot;]}}&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Say I want to add &lt;code&gt;&quot;test&quot;&lt;/code&gt; to this. How does one achieve this on the command line?&lt;/p&gt;
&lt;p&gt;Related: &lt;a rel=&quot;nofollow&quot; href=&quot;https://ask.clojure.org/index.php/10060/x-args-pass-in-entire-map-merge-strategy&quot;&gt;https://ask.clojure.org/index.php/10060/x-args-pass-in-entire-map-merge-strategy&lt;/a&gt;&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10059/x-args-add-things-to-vector</guid>
<pubDate>Fri, 15 Jan 2021 14:14:07 +0000</pubDate>
</item>
<item>
<title>Clojure Generation PDF blockchain</title>
<link>https://ask.clojure.org/index.php/9513/clojure-generation-pdf-blockchain</link>
<description>&lt;p&gt;Hi guys, I'm going to start developing a project and I want you to recommend some technologies that I can use and be useful for my project.&lt;/p&gt;
&lt;p&gt;Currently I have a system that generates PDF documents, but these documents do not have any type of security, what I want is: Generate PDF documents using blockchain and create a transactional query application for the generated documents&lt;/p&gt;
&lt;p&gt;Can someone make a recommendation to start my project?&lt;/p&gt;
&lt;p&gt;Thank you.!&lt;/p&gt;
</description>
<category>Docs</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9513/clojure-generation-pdf-blockchain</guid>
<pubDate>Mon, 27 Jul 2020 23:41:31 +0000</pubDate>
</item>
<item>
<title>Possibly revise s/merge behavior in spec.alpha2</title>
<link>https://ask.clojure.org/index.php/8844/possibly-revise-s-merge-behavior-in-spec-alpha2</link>
<description>&lt;p&gt;The example below shows that you can get generated values out of an s/merge using mult-specs that don't make sense with the intended spec.&lt;/p&gt;
&lt;p&gt;Looking at the implementation of the generator for s/merge each arg to s/merge gets generated individually, but it would be nice if they instead flowed through from right to left so things like multi-specs wouldn’t choose randomly from their dispatches.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  (s/def :ent/id string?)

  (defmulti ent-multi-id :ent/id)
  (defmethod ent-multi-id :default [_] (s/keys))

  (defn maybe-retag-fn [retag-k]
    (fn [gen-v dispatch-tag]
      (if (= dispatch-tag :default)
        gen-v
        (assoc gen-v retag-k dispatch-tag))))

  (s/def ::ent (s/merge (s/multi-spec ent-multi-id (maybe-retag-fn :ent/id))
                        (s/keys :req [:ent/id])))

  (gen/sample (s/gen ::ent) 5)
  ;; =&amp;gt; ({:ent/id &quot;&quot;} {:ent/id &quot;w&quot;} {:ent/id &quot;&quot;} {:ent/id &quot;66&quot;} {:ent/id &quot;63v&quot;})

  (s/def :foo/id string?)

  (defmethod ent-multi-id &quot;foo&quot; [_]
    (s/keys :req [:foo/id]))

  (gen/sample (s/gen ::ent) 5)
  ;; =&amp;gt; ({:foo/id &quot;&quot;, :ent/id &quot;&quot;} {:foo/id &quot;6&quot;, :ent/id &quot;f&quot;} {:foo/id &quot;A&quot;, :ent/id &quot;W&quot;} {:foo/id &quot;L&quot;, :ent/id &quot;nd&quot;} {:ent/id &quot;H&quot;})
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Spec</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/8844/possibly-revise-s-merge-behavior-in-spec-alpha2</guid>
<pubDate>Thu, 07 Nov 2019 17:31:28 +0000</pubDate>
</item>
</channel>
</rss>