<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent activity in Records and Types</title>
<link>https://ask.clojure.org/index.php/activity/clojure/records-and-types</link>
<description>Powered by Question2Answer</description>
<item>
<title>Commented: Is taggedliteral&#039;s equality check inefficient?</title>
<link>https://ask.clojure.org/index.php/15002/is-taggedliterals-equality-check-inefficient?show=15021#c15021</link>
<description>Uploaded a patch</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15002/is-taggedliterals-equality-check-inefficient?show=15021#c15021</guid>
<pubDate>Wed, 01 Apr 2026 17:31:34 +0000</pubDate>
</item>
<item>
<title>Commented: java.lang.NoClassDefFoundError: java/util/SequencedCollection</title>
<link>https://ask.clojure.org/index.php/13748/java-lang-noclassdeffounderror-java-sequencedcollection?show=14710#c14710</link>
<description>We have done some work on the bridge method issue for next Clojure release but it&amp;#039;s still a work in progress. I&amp;#039;m not sure whether that will actually avoid the issue or not though.&lt;br /&gt;
&lt;br /&gt;
We are also moving to a new JVM baseline for compiled code in the next release, but that will likely be 17 not 21, so probably will also not be a &amp;quot;fix&amp;quot;. For now, I would recommend to continue building with target of Java 8.</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13748/java-lang-noclassdeffounderror-java-sequencedcollection?show=14710#c14710</guid>
<pubDate>Thu, 11 Sep 2025 18:02:46 +0000</pubDate>
</item>
<item>
<title>Answered: defrecord qualified field names</title>
<link>https://ask.clojure.org/index.php/10160/defrecord-qualified-field-names?show=14269#a14269</link>
<description>&lt;p&gt;That syntax has the problem that you can&#039;t use keywords where the name part is the same. It wouldn&#039;t work with every keyword.&lt;/p&gt;
&lt;p&gt;I have multiple projects with keywords like :foo/id and :bar/id. When there is an entity that is related to both foo and bar, or if one of them is related to the other, then it&#039;s quite normal to have both in the same map. A typical has-a relation in a database.&lt;/p&gt;
&lt;p&gt;So this wouldn&#039;t work:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defrecord Example1 [foo/id bar/id])
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But if we change it to use the map destructuring syntax, you could give them non-conflicting names to use inside the record. Outside the record the keywords would be used. Like this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defrecord Example2 {foo-id :foo/id, bar-id :bar/id})
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10160/defrecord-qualified-field-names?show=14269#a14269</guid>
<pubDate>Fri, 22 Nov 2024 22:40:38 +0000</pubDate>
</item>
<item>
<title>Commented: Allow pre and post-conditions in defprotocol and deftype macros</title>
<link>https://ask.clojure.org/index.php/1944/allow-pre-and-post-conditions-defprotocol-and-deftype-macros?show=13243#c13243</link>
<description>It could be done on `defrecord` impls. It relies on `maybe-destructure`, following a similar code path as `fn`&amp;#039;s redefinition in `clojure/core.clj`. Could just copy-paste that in.&lt;br /&gt;
&lt;br /&gt;
I suspect this would work and work well, but i know there are edge cases I&amp;#039;m not considering and there&amp;#039;s probably some cost-benefit for speed etc that has been accounted for. @alexmiller, any thoughts?</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1944/allow-pre-and-post-conditions-defprotocol-and-deftype-macros?show=13243#c13243</guid>
<pubDate>Fri, 01 Sep 2023 19:56:34 +0000</pubDate>
</item>
<item>
<title>Retagged: defrecord should efficiently implement IReduceInit</title>
<link>https://ask.clojure.org/index.php/12576/defrecord-should-efficiently-implement-ireduceinit?show=12576#q12576</link>
<description>&lt;p&gt;In one my the TMD pathways (that came from mastodon) we expand the dataset size using defrecords.  Surprisingly considering everything else that performance case is doing, implementing IReduceInit spend up the timings considerably.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;
tech.v3.dataset.reductions-test&amp;gt; (require &#039;[criterium.core :as crit])
nil
tech.v3.dataset.reductions-test&amp;gt; (defrecord YMC [year-month ^long count]
  ;; clojure.lang.IReduceInit
  ;; (reduce [this rfn init]
  ;;   (let [init (reduced-&amp;gt; rfn init
  ;;                  (clojure.lang.MapEntry/create :year-month year-month)
  ;;                  (clojure.lang.MapEntry/create :count count))]
  ;;     (if (and __extmap (not (reduced? init)))
  ;;       (reduce rfn init __extmap)
  ;;       init)))
  )
tech.v3.dataset.reductions_test.YMC
tech.v3.dataset.reductions-test&amp;gt; (let [yc (YMC. :a 1)]
                                   (crit/quick-bench (reduce (fn [acc v] v) nil yc)))
Evaluation count : 6729522 in 6 samples of 1121587 calls.
             Execution time mean : 87.375170 ns
    Execution time std-deviation : 0.173728 ns
   Execution time lower quantile : 87.104982 ns ( 2.5%)
   Execution time upper quantile : 87.550708 ns (97.5%)
                   Overhead used : 2.017589 ns
nil
tech.v3.dataset.reductions-test&amp;gt; (defrecord YMC [year-month ^long count]
   clojure.lang.IReduceInit
   (reduce [this rfn init]
     (let [init (reduced-&amp;gt; rfn init
                    (clojure.lang.MapEntry/create :year-month year-month)
                    (clojure.lang.MapEntry/create :count count))]
       (if (and __extmap (not (reduced? init)))
         (reduce rfn init __extmap)
         init)))
  )
tech.v3.dataset.reductions_test.YMC
tech.v3.dataset.reductions-test&amp;gt; (let [yc (YMC. :a 1)]
                                   (crit/quick-bench (reduce (fn [acc v] v) nil yc)))
Evaluation count : 43415358 in 6 samples of 7235893 calls.
             Execution time mean : 11.775423 ns
    Execution time std-deviation : 0.197683 ns
   Execution time lower quantile : 11.594695 ns ( 2.5%)
   Execution time upper quantile : 12.079668 ns (97.5%)
                   Overhead used : 2.017589 ns
nil
tech.v3.dataset.reductions-test&amp;gt; (defmacro reduced-&amp;gt;
  [rfn acc &amp;amp; data]
  (reduce (fn [expr next-val]
            `(let [val# ~expr]
               (if (reduced? val#)
                 val#
                 (~rfn val# ~next-val))))
          acc
          data))

#&#039;tech.v3.dataset.reductions-test/reduced-&amp;gt;
tech.v3.dataset.reductions-test&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Talking this over with other members it appears the value lookup pathway could also be optimized in the case when __extmap is not nil (it uses clojure.core/get as opposed to a direct getorDefault call.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/techascent/tech.ml.dataset/blob/master/test/tech/v3/dataset/reductions_test.clj#L197&quot;&gt;https://github.com/techascent/tech.ml.dataset/blob/master/test/tech/v3/dataset/reductions_test.clj#L197&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12576/defrecord-should-efficiently-implement-ireduceinit?show=12576#q12576</guid>
<pubDate>Wed, 01 Mar 2023 16:14:52 +0000</pubDate>
</item>
<item>
<title>Commented: Add atomic field updaters to deftype</title>
<link>https://ask.clojure.org/index.php/10369/add-atomic-field-updaters-to-deftype?show=12338#c12338</link>
<description>Writing all that out it seems clear what my solution might be... to reference the app state directly from the table model and fire table structure/row/etc. changes when the app state changes. However, there&amp;#039;s a layer I didn&amp;#039;t mention. I&amp;#039;m actually using FRP (Functional Reactive Programming) for the UI. So the view is a function of the app state. The view function is a pure function, but because of how JTable is coded in Swing, it must contain a reference to the actual data. So either I create a new table model with each view rendering, store state within the table model using some custom or existing class, violate the FRP model for this case, or something I haven&amp;#039;t thought of.</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10369/add-atomic-field-updaters-to-deftype?show=12338#c12338</guid>
<pubDate>Fri, 28 Oct 2022 13:14:28 +0000</pubDate>
</item>
<item>
<title>Answer selected: Better generated arglists for map-&gt;SomeDefrecord</title>
<link>https://ask.clojure.org/index.php/12091/better-generated-arglists-for-map-somedefrecord?show=12096#a12096</link>
<description>&lt;p&gt;Logged as &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2714&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2714&lt;/a&gt;&lt;/p&gt;
</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12091/better-generated-arglists-for-map-somedefrecord?show=12096#a12096</guid>
<pubDate>Mon, 01 Aug 2022 20:20:22 +0000</pubDate>
</item>
<item>
<title>Commented: defrecord methods without using defprotocol</title>
<link>https://ask.clojure.org/index.php/11337/defrecord-methods-without-using-defprotocol?show=11340#c11340</link>
<description>&lt;a href=&quot;https://clojure.org/reference/datatypes&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.org/reference/datatypes&lt;/a&gt; Is the relevant doc explaining the motivations here</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11337/defrecord-methods-without-using-defprotocol?show=11340#c11340</guid>
<pubDate>Thu, 02 Dec 2021 13:18:26 +0000</pubDate>
</item>
<item>
<title>Answer selected: Record refinement feature</title>
<link>https://ask.clojure.org/index.php/9953/record-refinement-feature?show=9961#a9961</link>
<description>&lt;p&gt;I think it&#039;s highly unlikely that &quot;refinement&quot; would be considered as an enhancement due to the philosophical objection to concrete derivation.&lt;/p&gt;
&lt;p&gt;One way to handle this is to have the impls in R and Q call the same function. Another would be to use the lower level implementation features of protocols to externally supply the manipulated extension.&lt;/p&gt;
&lt;p&gt;A big benefit of protocols is that they can be extended externally, outside the type. Protocols are really just maps that contain a mapping of type to function impls. You could define a refine macro that expanded to pull the base impls, modify with refinements and add those methods to the protocol map. That&#039;s a bit too involved for me to write out, but it is possible.&lt;/p&gt;
&lt;p&gt;You could also use multimethods and the keyword hierarchy support as another option (with the downside of needing 10 multimethods or whatever). &lt;/p&gt;
</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9953/record-refinement-feature?show=9961#a9961</guid>
<pubDate>Tue, 22 Dec 2020 18:55:47 +0000</pubDate>
</item>
<item>
<title>Answered: generalizing isa?</title>
<link>https://ask.clojure.org/index.php/9204/generalizing-isa?show=9207#a9207</link>
<description>&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/reference/multimethods&quot;&gt;https://clojure.org/reference/multimethods&lt;/a&gt; is a pretty good overview of creating arbitrary keyword hierarchies and using &lt;code&gt;isa?&lt;/code&gt; for that.&lt;/p&gt;
&lt;p&gt;Not sure that I understand the type questions or Lisp context enough to answer the rest.&lt;/p&gt;
</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9204/generalizing-isa?show=9207#a9207</guid>
<pubDate>Wed, 01 Apr 2020 17:28:08 +0000</pubDate>
</item>
<item>
<title>Answered: how to check whether an object is of a certain type</title>
<link>https://ask.clojure.org/index.php/9205/how-to-check-whether-an-object-is-of-a-certain-type?show=9206#a9206</link>
<description>&lt;p&gt;These words are not being used interchangeably. &quot;class&quot; refers to the Java class hierarchy and can be checked with &lt;code&gt;instance?&lt;/code&gt;. &lt;/p&gt;
&lt;p&gt;&quot;type&quot; is the Java hierarchy &lt;em&gt;plus&lt;/em&gt; a Clojure-specific form of &quot;type tagging&quot; that can be used to create arbitrary hierarchies of keywords, most frequently used with multimethods. &lt;code&gt;isa?&lt;/code&gt; is the appropriate function for this broader context.&lt;/p&gt;
</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9205/how-to-check-whether-an-object-is-of-a-certain-type?show=9206#a9206</guid>
<pubDate>Wed, 01 Apr 2020 17:26:51 +0000</pubDate>
</item>
<item>
<title>Answered: Classes generated by deftype and defrecord don&#039;t play nice with .getPackage</title>
<link>https://ask.clojure.org/index.php/4617/classes-generated-deftype-defrecord-dont-play-getpackage?show=4673#a4673</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-1550&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-1550&lt;/a&gt; (reported by bozhidar)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4617/classes-generated-deftype-defrecord-dont-play-getpackage?show=4673#a4673</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
<item>
<title>Answered: cannot close over mutable fields (in deftype)</title>
<link>https://ask.clojure.org/index.php/3340/cannot-close-over-mutable-fields-in-deftype?show=3601#a3601</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-274&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-274&lt;/a&gt; (reported by alex+import)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3340/cannot-close-over-mutable-fields-in-deftype?show=3601#a3601</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
<item>
<title>Answered: defrecord positional arity factory fn should have an inline version that calls the record constructor</title>
<link>https://ask.clojure.org/index.php/3305/defrecord-positional-factory-should-version-constructor?show=3421#a3421</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-864&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-864&lt;/a&gt; (reported by hiredman)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3305/defrecord-positional-factory-should-version-constructor?show=3421#a3421</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
<item>
<title>Answered: records should support transient</title>
<link>https://ask.clojure.org/index.php/2401/records-should-support-transient?show=2660#a2660</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-1459&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-1459&lt;/a&gt; (reported by alex+import)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2401/records-should-support-transient?show=2660#a2660</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
<item>
<title>Answered: IKVReduce impl for records</title>
<link>https://ask.clojure.org/index.php/2386/ikvreduce-impl-for-records?show=2595#a2595</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-1880&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-1880&lt;/a&gt; (reported by gshayban)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2386/ikvreduce-impl-for-records?show=2595#a2595</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
<item>
<title>Answered: Enable refering to -&gt;type inside deftype</title>
<link>https://ask.clojure.org/index.php/1929/enable-refering-to-type-inside-deftype?show=2198#a2198</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-1044&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-1044&lt;/a&gt; (reported by bronsa)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1929/enable-refering-to-type-inside-deftype?show=2198#a2198</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
<item>
<title>Answered: Postcondition in defrecord: Compiler unable to resolve symbol %</title>
<link>https://ask.clojure.org/index.php/1521/postcondition-in-defrecord-compiler-unable-resolve-symbol?show=1663#a1663</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-1455&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-1455&lt;/a&gt; (reported by alex+import)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1521/postcondition-in-defrecord-compiler-unable-resolve-symbol?show=1663#a1663</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
<item>
<title>Answered: Support typed non-primitive fields in deftype</title>
<link>https://ask.clojure.org/index.php/1185/support-typed-non-primitive-fields-in-deftype?show=1433#a1433</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-252&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-252&lt;/a&gt; (reported by alex+import)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1185/support-typed-non-primitive-fields-in-deftype?show=1433#a1433</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
<item>
<title>Answered: Certain actions on mutable fields in deftype lead to very strange error messages</title>
<link>https://ask.clojure.org/index.php/768/certain-actions-mutable-fields-deftype-strange-error-messages?show=1045#a1045</link>
<description>Reference: &lt;a href=&quot;https://clojure.atlassian.net/browse/CLJ-1133&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://clojure.atlassian.net/browse/CLJ-1133&lt;/a&gt; (reported by alex+import)</description>
<category>Records and Types</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/768/certain-actions-mutable-fields-deftype-strange-error-messages?show=1045#a1045</guid>
<pubDate>Wed, 26 Jun 2019 12:00:00 +0000</pubDate>
</item>
</channel>
</rss>