<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions tagged destructuring</title>
<link>https://ask.clojure.org/index.php/tag/destructuring</link>
<description></description>
<item>
<title>Destructuring {:as opts} unexpected behaviour with seq</title>
<link>https://ask.clojure.org/index.php/15028/destructuring-as-opts-unexpected-behaviour-with-seq</link>
<description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I found out something weird in some old code, where I wanted to pass the first map in a sequence and by mistake the code was working while actually passing the sequence itself!&lt;/p&gt;
&lt;p&gt;After digging to make sense of this, I found out it has to do with the &lt;code&gt;{:as opts}&lt;/code&gt; destructuring.&lt;/p&gt;
&lt;p&gt;Here's some code:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; even if something is assigned sequential vs associative
;; the `:as` is transparent
(let [[:as opts] {1 2 3 4}]
  opts)
#_=&amp;gt; {1 2, 3 4}
(let [{:as opts} [1 2 3 4]]
  opts)
#_=&amp;gt; [1 2 3 4]
;; however with a seq it's returned as a map
(let [{:as opts} (seq [1 2 3 4])]
  opts)
#_=&amp;gt; {1 2, 3 4}

;; and it only gets weirder!
(let [{:as opts} (seq [{:k :v}])]
  opts)
#_=&amp;gt; {:k :v}
(let [{:as opts} (seq [{:k1 :v1} {:k2 :v2}])]
  opts)
#_=&amp;gt; {{:k1 :v1} {:k2 :v2}}
(let [{:as opts} (seq [{:k1 :v1} {:k2 :v2} {:k3 :v3}])]
  opts)
#_=&amp;gt; {{:k1 :v1} {:k2 :v2}, :k3 :v3}
(let [{:as opts} (seq [{:k1 :v1} {:k2 :v2} :not-a-map])]
  opts)
;; java.lang.IllegalArgumentException: Don't know how to create ISeq from: clojure.lang.Keyword
(let [{:as opts} (seq [1 2 3])]
  opts)
;; java.lang.IllegalArgumentException: Don't know how to create ISeq from: java.lang.Long
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In my case I didn't realize my code was wrong because &lt;code&gt;{:as opts} {:k :v}&lt;/code&gt; is the same as &lt;code&gt;{:as opts} (seq [{:k :v}])&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;To me this is behaviour I would expect closer to &lt;code&gt;&amp;amp; {:as opts}&lt;/code&gt; rather than just plain map destructuring &lt;code&gt;{:as opts}&lt;/code&gt;. Maybe both behaviours should be separated?&lt;/p&gt;
&lt;p&gt;I think this should be tackled either by&lt;br&gt;
1. make &lt;code&gt;:as&lt;/code&gt; transparent regardless of what comes in to always bind&lt;br&gt;
2. throw an error earlier when it's not of the expected destructuring&lt;br&gt;
3. Document this very unexpected edge case in &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/special_forms#associative-destructuring&quot;&gt;https://clojure.org/reference/special_forms#associative-destructuring&lt;/a&gt;&lt;br&gt;
4. Separate the keyword arguments use case from plain map destructuring? (Assuming both are now mixed together)&lt;/p&gt;
</description>
<category>Sequences</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15028/destructuring-as-opts-unexpected-behaviour-with-seq</guid>
<pubDate>Sat, 04 Apr 2026 23:50:39 +0000</pubDate>
</item>
<item>
<title>Consider postponing setting the default values of destructured map keys that might rely on other keys</title>
<link>https://ask.clojure.org/index.php/14478/consider-postponing-setting-default-values-destructured</link>
<description>&lt;p&gt;It's a rather frequent question where somebody gets a syntax error when trying to use something like &lt;code&gt;{:keys [a b ...] :or {b a}}&lt;/code&gt;. The most recent instance: &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojurians.slack.com/archives/C03S1KBA2/p1742549907988549&quot;&gt;https://clojurians.slack.com/archives/C03S1KBA2/p1742549907988549&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The error is as user-unfriendly as it gets and the behavior is also counter-intuitive if you don't happen to know the insides of destructuring and maps.&lt;/p&gt;
&lt;p&gt;Perhaps it would make sense to alter the destructuring impl for when the default value in &lt;code&gt;:or&lt;/code&gt; is not a primitive. So instead of being expanded to &lt;code&gt;b (get map__1 :b a)&lt;/code&gt; it's expanded to &lt;code&gt;b (get map__1 :b ::not-found)&lt;/code&gt; with a subsequent rebinding to &lt;code&gt;b (if (identical? b ::not-found) a b)&lt;/code&gt; after all the other keys have already been extracted.&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14478/consider-postponing-setting-default-values-destructured</guid>
<pubDate>Fri, 21 Mar 2025 10:04:09 +0000</pubDate>
</item>
<item>
<title>ClojureScript: Destructuring two keys differing only on dash vs underscore doesn't work</title>
<link>https://ask.clojure.org/index.php/14370/clojurescript-destructuring-differing-underscore-doesnt</link>
<description>&lt;p&gt;When i try to destructure a key, supporting both kebab and snake case I run in to trouble:&lt;/p&gt;
&lt;p&gt;Sometimes both symbols pick up the same value:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [{:keys [foo-bar foo_bar] :as m} {:foo_bar 42}]
  [foo-bar (:foo-bar m) foo_bar (:foo_bar m)])
;;=&amp;gt; [42 nil 42 42]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Other times one symbol overshadows the other one:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [{:keys [foo-bar foo_bar
              a b c d e f g] :as m} {:foo_bar 42}]
  [foo-bar (:foo-bar m) foo_bar (:foo_bar m)])
;;=&amp;gt; [nil nil nil 42]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;At least that's what I think is going on there: &lt;code&gt;foo-bar&lt;/code&gt; doesn't exist and gets the value &lt;code&gt;nil&lt;/code&gt;, overshadowing the symbol &lt;code&gt;foo_bar&lt;/code&gt; for which the value exists.&lt;/p&gt;
&lt;p&gt;This is supposedly a known limitation in ClojureScript, but I couldn't find it in &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/jira/software/c/projects/CLJS/issues&quot;&gt;the issue tracker&lt;/a&gt;. Nor does it seem like ChatGPT knows about it. Maybe it helps a bit to have it visible here for bots and humans alike.&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14370/clojurescript-destructuring-differing-underscore-doesnt</guid>
<pubDate>Mon, 03 Feb 2025 16:09:41 +0000</pubDate>
</item>
<item>
<title>destructuring  corner case:  [&amp; {:as key-vals}]</title>
<link>https://ask.clojure.org/index.php/14005/destructuring-corner-case-as-key-vals</link>
<description>&lt;p&gt;I don't find the behavior of the following expression documented.&lt;br&gt;
Can someone either point me to the documentation, or I request&lt;br&gt;
that the documentation be updated to warn about this caveat.&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/guides/destructuring&quot;&gt;https://clojure.org/guides/destructuring&lt;/a&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;((fn [&amp;amp; {:as key-vals}] key-vals) :a 100 :b 200) ;; case 1
(let [[&amp;amp; {:as key-vals}] '(:a 100 :b 200)] key-vals) ;; case 2
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;These both evaluate to a map &lt;code&gt;{:a 100 :b 200)&lt;/code&gt;.  However, the following evaluate to &lt;code&gt;nil&lt;/code&gt; rather than an empty map.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;((fn [&amp;amp; {:as key-vals}] key-vals) ) ;; case 3
(let [[&amp;amp; {:as key-vals}] ()] key-vals)  ;; case 4
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The tag &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/guides/destructuring#_keyword_arguments&quot;&gt;https://clojure.org/guides/destructuring#_keyword_arguments&lt;/a&gt; does not exactly say what happens in these cases; however, intuitively I'd expect that key-vals should be a map in all 4 cases.  Instead it is a map in the first to cases, but is &lt;code&gt;nil&lt;/code&gt; in cases 3 and 4.  I'd expect cases 3 and 4 to each evaluate to an empty map.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14005/destructuring-corner-case-as-key-vals</guid>
<pubDate>Wed, 03 Jul 2024 11:49:12 +0000</pubDate>
</item>
<item>
<title>Wrong line number reported for exceptions thrown by code generated by destructuring</title>
<link>https://ask.clojure.org/index.php/13605/number-reported-exceptions-thrown-generated-destructuring</link>
<description>&lt;p&gt;Put anywhere in &lt;code&gt;bad_line_number.clj&lt;/code&gt;, run with &lt;code&gt;clj -J-Dclojure.main.report=stderr -Sdeps '{:paths [&quot;.&quot;]}' -M -m bad-line-number&lt;/code&gt; from the same dir.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(ns bad-line-number)

(defn returns-a-tuple []
  [{1 2} :wrapped])

(defn should-also-return-a-tuple-but-doesnt [data]
  {data :unwrapped})

(defn -main []
  (let [[a fmt] (returns-a-tuple)
        data
        (try
          (should-also-return-a-tuple-but-doesnt a)
          (catch Throwable _
            (println &quot;Unable to create a map&quot;)
            [3 4]))

        [x y]
        (case fmt
          :wrapped data
          :unwrapped [data nil])]
    [x y]))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Running that code results in &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;{:clojure.main/message
 &quot;Execution error (UnsupportedOperationException) at bad-line-number/-main (bad_line_number.clj:10).\nnth not supported on this type: PersistentArrayMap\n&quot;,
 :clojure.main/triage
 {:clojure.error/class java.lang.UnsupportedOperationException,
  :clojure.error/line 10,
  :clojure.error/cause
  &quot;nth not supported on this type: PersistentArrayMap&quot;,
  :clojure.error/symbol bad-line-number/-main,
  :clojure.error/source &quot;bad_line_number.clj&quot;,
  :clojure.error/phase :execution},
 :clojure.main/trace
 {:via
  [{:type java.lang.UnsupportedOperationException,
    :message &quot;nth not supported on this type: PersistentArrayMap&quot;,
    :at [clojure.lang.RT nthFrom &quot;RT.java&quot; 992]}],
  :trace
  [[clojure.lang.RT nthFrom &quot;RT.java&quot; 992]
   [clojure.lang.RT nth &quot;RT.java&quot; 940]
   [bad_line_number$_main invokeStatic &quot;bad_line_number.clj&quot; 10]
   [bad_line_number$_main invoke &quot;bad_line_number.clj&quot; 9]
   [clojure.lang.AFn applyToHelper &quot;AFn.java&quot; 152]
   [clojure.lang.AFn applyTo &quot;AFn.java&quot; 144]
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
   [clojure.core$apply invokeStatic &quot;core.clj&quot; 667]
   [clojure.main$main_opt invokeStatic &quot;main.clj&quot; 514]
   [clojure.main$main_opt invoke &quot;main.clj&quot; 510]
   [clojure.main$main invokeStatic &quot;main.clj&quot; 664]
   [clojure.main$main doInvoke &quot;main.clj&quot; 616]
   [clojure.lang.RestFn applyTo &quot;RestFn.java&quot; 137]
   [clojure.lang.Var applyTo &quot;Var.java&quot; 705]
   [clojure.main main &quot;main.java&quot; 40]],
  :cause &quot;nth not supported on this type: PersistentArrayMap&quot;}}

Execution error (UnsupportedOperationException) at bad-line-number/-main (bad_line_number.clj:10).
nth not supported on this type: PersistentArrayMap
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, it refers to line 10, which has &lt;code&gt;(let [[a fmt] (returns-a-tuple)&lt;/code&gt;, so naturally the first line of thinking is &quot;&lt;code&gt;returns-a-tuple&lt;/code&gt; somehow returns a map, and that's what I need to investigate&quot;.&lt;br&gt;
Just spent a few hours chasing that goose when it's actually &lt;code&gt;should-also-return-a-tuple-but-doesnt&lt;/code&gt; that's to blame.&lt;/p&gt;
</description>
<category>Errors</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13605/number-reported-exceptions-thrown-generated-destructuring</guid>
<pubDate>Sat, 06 Jan 2024 10:56:33 +0000</pubDate>
</item>
<item>
<title>:or destructuring doesn't update object</title>
<link>https://ask.clojure.org/index.php/13141/or-destructuring-doesnt-update-object</link>
<description>&lt;p&gt;This is related to a number of other asks/jira tickets but I haven't found one for this specifically.&lt;/p&gt;
&lt;p&gt;Because &lt;code&gt;:or&lt;/code&gt; is destructured into &lt;code&gt;not-found&lt;/code&gt; values of the &lt;code&gt;get&lt;/code&gt; calls for the destructured keys/symbols/etc, if you bind an object with &lt;code&gt;:as&lt;/code&gt; and include defaults in &lt;code&gt;:or&lt;/code&gt;, the object won't have the defaults:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn example [{:keys [a b]
                :or {a 1 b 2}
                :as opts}]
  (println a b opts))

(example {:a 5})
;=&amp;gt; 5 2 {:a 5}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This has led to subtle bugs in our codebase where we expected the defaults to exist and then they didn't, or we used &lt;code&gt;{:pre [some-pred]}&lt;/code&gt; to check an invariant which was violated when we modified the function to use &lt;code&gt;:as&lt;/code&gt; in addition to the specific values.&lt;/p&gt;
&lt;p&gt;To merge them, you'd want to build the map and then &lt;code&gt;opts (conj defaults-map opts)&lt;/code&gt;, but that requires iterating over the keys/syms/strs a second time, selecting only the names in the &lt;code&gt;:or&lt;/code&gt; map and requires creating another map, or maybe calling &lt;code&gt;assoc&lt;/code&gt; repeatedly.&lt;/p&gt;
&lt;p&gt;I think it's doable, it would just be a little annoying to write.&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13141/or-destructuring-doesnt-update-object</guid>
<pubDate>Mon, 07 Aug 2023 20:11:20 +0000</pubDate>
</item>
<item>
<title>Map destructuring works on singleton lists</title>
<link>https://ask.clojure.org/index.php/12374/map-destructuring-works-on-singleton-lists</link>
<description>&lt;p&gt;(let [{x :x} '({:x &quot;foo&quot;})]  x)&lt;br&gt;
;; =&amp;gt; &quot;foo&quot;&lt;/p&gt;
</description>
<category>ClojureScript</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12374/map-destructuring-works-on-singleton-lists</guid>
<pubDate>Thu, 10 Nov 2022 08:15:43 +0000</pubDate>
</item>
<item>
<title>Has middle of sequence &amp;rest destructuring been considered?</title>
<link>https://ask.clojure.org/index.php/11985/has-middle-of-sequence-rest-destructuring-been-considered</link>
<description>&lt;p&gt;Currently, Clojure allows for destructuring patterns that contain &amp;amp;rest arguments:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (let [[a b &amp;amp; c] (range 5)] [a b c])
[0 1 (2 3 4)]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Python allows for the same, but also for placing the so-called catch-all in the front and middle position as well (&lt;a rel=&quot;nofollow&quot; href=&quot;https://peps.python.org/pep-3132/&quot;&gt;PEP description&lt;/a&gt;):&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; a, *b, c = range(5)
&amp;gt;&amp;gt;&amp;gt; a
0
&amp;gt;&amp;gt;&amp;gt; c
4
&amp;gt;&amp;gt;&amp;gt; b
[1, 2, 3]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Has similar been considered for Clojure? Could look like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (let [[a &amp;amp; b c] (range 5)] [a b c])
[0 (1 2 3) 4]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I feel like this would be doable with how the core functions destructure currently works, but it’s possible I don’t know some subtlety. &lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11985/has-middle-of-sequence-rest-destructuring-been-considered</guid>
<pubDate>Mon, 20 Jun 2022 13:23:18 +0000</pubDate>
</item>
<item>
<title>Rest for map destructuring</title>
<link>https://ask.clojure.org/index.php/11184/rest-for-map-destructuring</link>
<description>&lt;p&gt;I suggest adding &lt;code&gt;:rest&lt;/code&gt; key for map destructuring syntax. &lt;br&gt;
How do you think the following feature would be useful?&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [m {:a 1 :b 2}
      {:keys [a] :rest r} m]
  (assert (= {:b 2} r)))
      
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Or even like the rest of an array &lt;code&gt;[a b &amp;amp; r]&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [m {:a 1 :b 2}
      {:keys [a]
       :&amp;amp; r} m]
  (assert (= {:b 2} r)))
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Collections</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11184/rest-for-map-destructuring</guid>
<pubDate>Mon, 25 Oct 2021 10:04:49 +0000</pubDate>
</item>
<item>
<title>Using (s/or) without destructuring</title>
<link>https://ask.clojure.org/index.php/9844/using-s-or-without-destructuring</link>
<description>&lt;p&gt;I have a sequence of characters, and am trying to use (s/cat ...) with (s/or) in order to conform the sequence.&lt;/p&gt;
&lt;p&gt;The input could look something like &lt;code&gt;[0 1 2 3]&lt;/code&gt; or &lt;code&gt;[\a \b \c \d]&lt;/code&gt; and I am trying to use this spec.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(s/conform (s/cat :top (s/or :nums (s/+ #{0 1 2 3 4})
                             :letters (s/+ #{\a \b \c \d})
                  ... more stuff))
           [0 1 2 3])
=&amp;gt; :clojure.spec.alpha/invalid
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Not using the &lt;code&gt;(s/or)&lt;/code&gt; works if I choose one of &lt;code&gt;:nums&lt;/code&gt; or &lt;code&gt;:letters&lt;/code&gt;.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(s/conform (s/cat :first-set (s/+ #{0 1 2 3 4}))
           [0 1 2 3])
=&amp;gt; {:first-set [0 1 2 3]}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The initial example works if the entire sequence is wrapped in another vec, but this isn't what I want.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(s/conform (s/cat :first-set (s/or :nums (s/+ #{0 1 2 3 4})
                                   :letters (s/+ #{\a \b \c \d})))
           [[0 1 2 3]])
=&amp;gt; {:first-set [:nums [0 1 2 3]]}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using &lt;code&gt;(or ...)&lt;/code&gt; also seems to only work inside &lt;code&gt;(s/keys)&lt;/code&gt;. I'm guessing it's because the &lt;code&gt;(or&lt;/code&gt; always takes the first spec because it's not falsy.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(s/conform (s/cat :first-set (or (s/+ #{0 1 2 3 4})
                                 (s/+ #{\a \b \c \d})))
           [0 1 2 3])
=&amp;gt; {:first-set [0 1 2 3]}

(s/conform (s/cat :first-set (or (s/+ #{0 1 2 3 4})
                                 (s/+ #{\a \b \c \d})))
           [\a \b \c])
=&amp;gt; :clojure.spec.alpha/invalid
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This is what I want to happen.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(s/conform (s/cat :first-set (s/something-here (s/+ #{0 1 2 3 4})
                                               (s/+ #{\a \b \c \d})))
           [0 1 2 3])
=&amp;gt; {:first-set [0 1 2 3]}

(s/conform (s/cat :first-set (s/something-here (s/+ #{0 1 2 3 4})
                                               (s/+ #{\a \b \c \d})))
           [\a \b \c])
=&amp;gt; {:first-set [\a \b \c]}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I'm wondering what to do here.&lt;/p&gt;
</description>
<category>Spec</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9844/using-s-or-without-destructuring</guid>
<pubDate>Sun, 22 Nov 2020 19:20:02 +0000</pubDate>
</item>
<item>
<title>Order of key destructuring in :or</title>
<link>https://ask.clojure.org/index.php/9746/order-of-key-destructuring-in-or</link>
<description>&lt;p&gt;I was under the assumption that &lt;code&gt;{:keys [a b c d]}&lt;/code&gt; was destructured in the order of &lt;code&gt;a-&amp;gt;b-&amp;gt;c-&amp;gt;d&lt;/code&gt; which is proven below&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;haystack.core=&amp;gt; (clojure.pprint/pprint (destructure '[{:keys [a b c d] :as options} {}]))
[map__14131
 {}
 map__14131
 (if
  (clojure.core/seq? map__14131)
  (clojure.lang.PersistentHashMap/create (clojure.core/seq map__14131))
  map__14131)
 options
 map__14131
 a
 (clojure.core/get map__14131 :a)
 b
 (clojure.core/get map__14131 :b)
 c
 (clojure.core/get map__14131 :c)
 d
 (clojure.core/get map__14131 :d)]
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;however, when the keys vector has elements &amp;gt; 10, the order changes all of a sudden&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;haystack.core=&amp;gt; (clojure.pprint/pprint (destructure '[{:keys [a b c d e f g h i j] :as options} {}]))
[map__14137
 {}
 map__14137
 (if
  (clojure.core/seq? map__14137)
  (clojure.lang.PersistentHashMap/create (clojure.core/seq map__14137))
  map__14137)
 options
 map__14137
 i
 (clojure.core/get map__14137 :i)
 a
 (clojure.core/get map__14137 :a)
 e
 (clojure.core/get map__14137 :e)
 c
 (clojure.core/get map__14137 :c)
 g
 (clojure.core/get map__14137 :g)
 j
 (clojure.core/get map__14137 :j)
 h
 (clojure.core/get map__14137 :h)
 b
 (clojure.core/get map__14137 :b)
 d
 (clojure.core/get map__14137 :d)
 f
 (clojure.core/get map__14137 :f)]
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I couldn't find anything in the destructure source code&lt;/p&gt;
</description>
<category>Clojure</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9746/order-of-key-destructuring-in-or</guid>
<pubDate>Mon, 02 Nov 2020 09:16:39 +0000</pubDate>
</item>
<item>
<title>Has the destructuring spec changed since 1.8.0?</title>
<link>https://ask.clojure.org/index.php/9643/has-the-destructuring-spec-changed-since-1-8-0</link>
<description>&lt;p&gt;1.8.0:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj-rcon-test.core=&amp;gt; (defn- hi [as-codec &amp;amp; {:keys [offset] :or {:offset 0}}]
                #_=&amp;gt;   (println &quot;hi&quot;))
#'clj-rcon-test.core/hi
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;1.10.0:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;clj-rcon-test.core=&amp;gt; (defn- hi [as-codec &amp;amp; {:keys [offset] :or {:offset 0}}]
                #_=&amp;gt;   (println &quot;hi&quot;))
Syntax error macroexpanding clojure.core/defn- at (form-init17556793069765460591.clj:1:1).
:offset - failed: simple-symbol? at: [:fn-tail :arity-1 :params :var-params :var-form :map-destructure :or 0] spec: :clojure.core.specs.alpha/or
{:keys [offset], :or {:offset 0}} - failed: simple-symbol? at: [:fn-tail :arity-1 :params :var-params :var-form :local-symbol] spec: :clojure.core.specs.alpha/local-name
{:keys [offset], :or {:offset 0}} - failed: vector? at: [:fn-tail :arity-1 :params :var-params :var-form :seq-destructure] spec: :clojure.core.specs.alpha/seq-binding-form
as-codec - failed: vector? at: [:fn-tail :arity-n :bodies :params] spec: :clojure.core.specs.alpha/param-list

clj-rcon-test.core=&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For context this is what I'm trying to troubleshoot: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/gpittarelli/clj-rcon/blob/master/src/clj_rcon/codecs.clj#L6&quot;&gt;https://github.com/gpittarelli/clj-rcon/blob/master/src/clj_rcon/codecs.clj#L6&lt;/a&gt;&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9643/has-the-destructuring-spec-changed-since-1-8-0</guid>
<pubDate>Fri, 25 Sep 2020 15:24:01 +0000</pubDate>
</item>
<item>
<title>Missing error on silly destructuring mistake</title>
<link>https://ask.clojure.org/index.php/9590/missing-error-on-silly-destructuring-mistake</link>
<description>&lt;p&gt;I happened to define a function like this&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn foo [{:keys [bar :as lol]}] lol)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Obviously the destructuring is wrong, it should have been&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn foo [{:keys [bar] :as lol}] lol)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;My question is then, should this destructuring error be caught by the specs for destructuring?&lt;/p&gt;
</description>
<category>Syntax and reader</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9590/missing-error-on-silly-destructuring-mistake</guid>
<pubDate>Wed, 09 Sep 2020 07:32:08 +0000</pubDate>
</item>
</channel>
</rss>