<?xml version="1.0" encoding="utf-8"?> 
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
 <title type="text">Fragments: Posts tagged 'releases'</title>
 <link rel="self" href="https://www.tfeb.org/fragments/feeds/releases.atom.xml" />
 <link href="https://www.tfeb.org/fragments/tags/releases.html" />
 <id>urn:https-www-tfeb-org:-fragments-tags-releases-html</id>
 <updated>2025-11-27T11:50:16Z</updated>
 <entry>
  <title type="text">A timing macro for Common Lisp</title>
  <link rel="alternate" href="https://www.tfeb.org/fragments/2025/11/27/a-timing-macro-for-common-lisp/?utm_source=releases&amp;utm_medium=Atom" />
  <id>urn:https-www-tfeb-org:-fragments-2025-11-27-a-timing-macro-for-common-lisp</id>
  <published>2025-11-27T11:50:16Z</published>
  <updated>2025-11-27T11:50:16Z</updated>
  <author>
   <name>Tim Bradshaw</name></author>
  <content type="html">
&lt;p&gt;For a long time I&amp;rsquo;ve used a little macro to time chunks of code to avoid an endless succession of boilerplate functions to do this. I&amp;rsquo;ve finally published the wretched thing.&lt;/p&gt;
&lt;!-- more--&gt;

&lt;p&gt;If you&amp;rsquo;re writing programs where you care about performance, you often want to be able to make programatic comparisons of performance. &lt;code&gt;time&lt;/code&gt; doesn&amp;rsquo;t do this, since it just reports things. Instead you want something that runs a bit of code a bunch of times and then returns the average time, with &amp;lsquo;a bunch of times&amp;rsquo; being controllable. &lt;code&gt;timing&lt;/code&gt; is that macro. Here is a simple example:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(defun dotimes/in-naturals-ratio (&amp;amp;key (iters 10000000) (tries 1000))
  (declare (type fixnum iters)
           (optimize speed))
  (/
   (timing (:n tries)
     (let ((s 0))                       ;avoid optimizing loop away
       (declare (type fixnum s))
       (dotimes (i iters s)
         (incf s))))
   (timing (:n tries)
     (let ((s 0))
       (declare (type fixnum s))
       (for ((_ (in-naturals iters t)))
         (incf s))))))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and then, for instance&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;gt; (dotimes/in-naturals-ratio)
1.0073159&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;All &lt;code&gt;timing&lt;/code&gt; does is to wrap up its body into a function and then call a function which calls this function the number of times you specify and averages the time, returning that average as a float.&lt;/p&gt;

&lt;p&gt;There are some options which let it print a progress note every given number of calls, wrap a call to &lt;code&gt;time&lt;/code&gt; around things so you get, for instance, GC reporting, and subtract away the same number of calls to an empty function to try and account for overhead (in practice this is not very useful).&lt;/p&gt;

&lt;p&gt;That&amp;rsquo;s all it is. It&amp;rsquo;s available in version 10 of my Lisp tools:&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;documentation &lt;a href="https://tfeb.org/fragments/documentation/tfeb-lisp-tools.html"&gt;here&lt;/a&gt;;&lt;/li&gt;
 &lt;li&gt;git repo &lt;a href="https://tfeb.org/computer/repos/tfeb-lisp-tools.git"&gt;here&lt;/a&gt;;&lt;/li&gt;
 &lt;li&gt;tarball &lt;a href="https://tfeb.org/computer/tarballs/tfeb-lisp-tools.tar.gz"&gt;here&lt;/a&gt;.&lt;/li&gt;&lt;/ul&gt;</content></entry>
 <entry>
  <title type="text">Tracing the expansion of external macros</title>
  <link rel="alternate" href="https://www.tfeb.org/fragments/2025/10/10/tracing-the-expansion-of-external-macros/?utm_source=releases&amp;utm_medium=Atom" />
  <id>urn:https-www-tfeb-org:-fragments-2025-10-10-tracing-the-expansion-of-external-macros</id>
  <published>2025-10-10T10:39:18Z</published>
  <updated>2025-10-10T10:39:18Z</updated>
  <author>
   <name>Tim Bradshaw</name></author>
  <content type="html">
&lt;p&gt;I have improved my &lt;code&gt;trace-macroexpand&lt;/code&gt; system so you can say, in effect &amp;lsquo;trace the expansion of only the macros in the interface to a given package&amp;rsquo;. This is a fairly useful thing.&lt;/p&gt;
&lt;!-- more--&gt;

&lt;p&gt;Tracing macroexpansion in Common Lisp is a pretty useful thing to be able to do, in my experience. It is completely possible to do this in portable CL via &lt;a href="https://www.lispworks.com/documentation/HyperSpec/Body/v_mexp_h.htm"&gt;&lt;code&gt;*macroexpand-hook*&lt;/code&gt;&lt;/a&gt;: you simply put your tracing function on this hook, making sure it actually does expand the macro. &lt;a href="https://tfeb.org/fragments/documentation/tfeb-lisp-hax.html#tracing-macroexpansion-trace-macroexpand"&gt;&lt;code&gt;trace-macroexpand&lt;/code&gt;&lt;/a&gt; does just this, and lets you specify which macros you want to be traced.&lt;/p&gt;

&lt;p&gt;It has always allowed you to say &amp;lsquo;trace all macros whose home package is this package&amp;rsquo;. That&amp;rsquo;s less useful than you might think:&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;it means that not only macros whose names are exported from the packqge are traced, but any macros in its guts are also traced, which generally a user of the package should not be interested in;&lt;/li&gt;
 &lt;li&gt;it &lt;em&gt;doesn&amp;rsquo;t&lt;/em&gt; trace macros which are exported from a package but whose home package is not that package.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Very often the second thing is exactly what you want: you want to be able to say &amp;lsquo;let me see the expansion of macros in the public interface to this package, but I don&amp;rsquo;t care about the internal details of it&amp;rsquo;.&lt;/p&gt;

&lt;p&gt;It can now do exactly that.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;trace-macro-package&lt;/code&gt; now takes a list of &lt;em&gt;package specifiers&lt;/em&gt;. If a package specifier is a list of one or more other package specifiers, then it changes their meaning to be &amp;lsquo;trace the exports of these packages only&amp;rsquo;.&lt;/p&gt;

&lt;p&gt;Here is an example:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;&amp;gt; (find-symbol "FOR" :org.tfeb.star)
for
:external

&amp;gt; (symbol-package *)
#&amp;lt;The ORG.TFEB.STAR/IMPL package, 188/512 internal, 6/16 external&amp;gt;

&amp;gt; (trace-macroexpand t)
nil

&amp;gt; (setf *trace-macroexpand-per-line-prefix* "| ")
"| "

&amp;gt; (trace-macro-package :org.tfeb.star)
("ORG.TFEB.STAR")

&amp;gt; (for ((_ (in-naturals 10))))
nil

&amp;gt; (untrace-macro-package :org.tfeb.star)
nil

&amp;gt; (trace-macro-package '(:org.tfeb.star))
(("ORG.TFEB.STAR"))

&amp;gt; (for ((_ (in-naturals 10))))
| (for (#))
|  -&amp;gt; (multiple-value-bind (#:&amp;lt;v&amp;gt;) 0 ...)
nil&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;As well as this, both &lt;code&gt;trace-macro-package&lt;/code&gt; and &lt;code&gt;untrace-macro-package&lt;/code&gt; now &lt;em&gt;canonicalise&lt;/em&gt; the specifiers they are given, which means, for instance that &lt;code&gt;(trace-macro-package '("FOO" "BAR"))&lt;/code&gt; is exactly the same as &lt;code&gt;(trace-macro-package '("FOO") '("BAR"))&lt;/code&gt;: this means that things like&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;&amp;gt; (trace-macro-package '("FOO" "BAR"))

[...]

&amp;gt; (untrace-macro-package '("FOO"))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;will work properly.&lt;/p&gt;

&lt;p&gt;This change is in version 10.9.0 of the &lt;a href="https://tfeb.org/fragments/documentation/tfeb-lisp-hax.html"&gt;TFEB.ORG Lisp hax&lt;/a&gt;, &lt;a href="https://tfeb.org/computer/repos/tfeb-lisp-hax.git"&gt;git repo&lt;/a&gt;.&lt;/p&gt;</content></entry>
 <entry>
  <title type="text">Optional per-line prefix for trace-macroexpand</title>
  <link rel="alternate" href="https://www.tfeb.org/fragments/2025/10/08/optional-per-line-prefix-for-trace-macroexpand/?utm_source=releases&amp;utm_medium=Atom" />
  <id>urn:https-www-tfeb-org:-fragments-2025-10-08-optional-per-line-prefix-for-trace-macroexpand</id>
  <published>2025-10-08T16:52:23Z</published>
  <updated>2025-10-08T16:52:23Z</updated>
  <author>
   <name>Tim Bradshaw</name></author>
  <content type="html">
&lt;p&gt;My &lt;a href="https://tfeb.org/fragments/documentation/tfeb-lisp-hax.html#tracing-macroexpansion-trace-macroexpand"&gt;macroexpansion tracer&lt;/a&gt; can now print per-line prefixes when tracing, which can make things more readable.&lt;/p&gt;
&lt;!-- more--&gt;

&lt;p&gt;I find &lt;code&gt;trace-macroexpand&lt;/code&gt; pretty useful: if you write Lisp with lots of nontrivial macros&lt;sup&gt;&lt;a href="#2025-10-08-optional-per-line-prefix-for-trace-macroexpand-footnote-1-definition" name="2025-10-08-optional-per-line-prefix-for-trace-macroexpand-footnote-1-return"&gt;1&lt;/a&gt;&lt;/sup&gt; then it can be fairly hard to understand what&amp;rsquo;s going on when something is not working properly. &lt;code&gt;trace-macroexpand&lt;/code&gt; lets you see this either for individual macros or many of them. It can, portably, trace any macro including ones defined by CL, which is even nicer.&lt;/p&gt;

&lt;p&gt;However it&amp;rsquo;s not always easy to distinguish its output from other output. So, I realised I could add a per-line prefix which can help distinguish its output. Here is an example.&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;&amp;gt; (defvar *a* (cons nil nil))
*a*

&amp;gt; (trace-macroexpand t)
nil

&amp;gt; (trace-macro setf)
(setf)

&amp;gt; (setf (car *a*) 10)
(setf (car *a*) 10)
 -&amp;gt; (system::%rplaca *a* 10)
10

&amp;gt; (setf *trace-macroexpand-per-line-prefix* "| ")
(setf *trace-macroexpand-per-line-prefix* "| ")
 -&amp;gt; (let* (#) (setq *trace-macroexpand-per-line-prefix* #:|Store-Var-1692|))
"| "

&amp;gt; (setf (car *a*) 11)
| (setf (car *a*) 11)
|  -&amp;gt; (system::%rplaca *a* 11)
11&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is in version 10.8.1&lt;sup&gt;&lt;a href="#2025-10-08-optional-per-line-prefix-for-trace-macroexpand-footnote-2-definition" name="2025-10-08-optional-per-line-prefix-for-trace-macroexpand-footnote-2-return"&gt;2&lt;/a&gt;&lt;/sup&gt; of the &lt;a href="https://tfeb.org/fragments/documentation/tfeb-lisp-hax.html"&gt;TFEB.ORG Lisp hax&lt;/a&gt;, &lt;a href="https://tfeb.org/computer/repos/tfeb-lisp-hax.git"&gt;git repo&lt;/a&gt;.&lt;/p&gt;

&lt;hr /&gt;

&lt;div class="footnotes"&gt;
 &lt;ol&gt;
  &lt;li id="2025-10-08-optional-per-line-prefix-for-trace-macroexpand-footnote-1-definition" class="footnote-definition"&gt;
   &lt;p&gt;If you aren&amp;rsquo;t doing that, why are you writing Lisp at all?&amp;nbsp;&lt;a href="#2025-10-08-optional-per-line-prefix-for-trace-macroexpand-footnote-1-return"&gt;↩&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
  &lt;li id="2025-10-08-optional-per-line-prefix-for-trace-macroexpand-footnote-2-definition" class="footnote-definition"&gt;
   &lt;p&gt;10.8.0 had a stupid bug.&amp;nbsp;&lt;a href="#2025-10-08-optional-per-line-prefix-for-trace-macroexpand-footnote-2-return"&gt;↩&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;</content></entry>
 <entry>
  <title type="text">Defaulting places in Common Lisp</title>
  <link rel="alternate" href="https://www.tfeb.org/fragments/2025/10/07/defaulting-places-in-common-lisp/?utm_source=releases&amp;utm_medium=Atom" />
  <id>urn:https-www-tfeb-org:-fragments-2025-10-07-defaulting-places-in-common-lisp</id>
  <published>2025-10-07T11:50:22Z</published>
  <updated>2025-10-07T11:50:22Z</updated>
  <author>
   <name>Tim Bradshaw</name></author>
  <content type="html">
&lt;p&gt;Or: less boilerplate.&lt;/p&gt;
&lt;!-- more--&gt;

&lt;p&gt;Common Lisp (CL) has a general notion of a &lt;a href="https://www.lispworks.com/documentation/HyperSpec/Body/05_a.htm" title="Generalized reference"&gt;&lt;em&gt;place&lt;/em&gt;&lt;/a&gt;, which is a form which has a value or values and into which a value or values can be stored. Variables are places, but so are forms like &lt;code&gt;(car c)&lt;/code&gt;: &lt;code&gt;(setf (car c) 2)&lt;/code&gt; will store 2 into the car of the cons bound to &lt;code&gt;c&lt;/code&gt;. Places can even store multiple values:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(let ((a 1) (b 3))
  (setf (values a b) (values 3 4))
  (values a b))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;for instance. Here the place is &lt;code&gt;(values a b)&lt;/code&gt; which is a place composed of two other places.&lt;/p&gt;

&lt;p&gt;This is a really useful notion, not only because places mean the language no longer needs all sorts of special-purpose mutation functions &amp;mdash; &lt;code&gt;rplaca&lt;/code&gt; still exists for compatibility but there is no &lt;code&gt;sethash&lt;/code&gt; or &lt;code&gt;aset&lt;/code&gt; &amp;mdash; but because you can implement your own places which behave just like the ones the language provides.&lt;/p&gt;

&lt;p&gt;Here&amp;rsquo;s an example of a place called a &amp;lsquo;wrapped alist&amp;rsquo;: it&amp;rsquo;s just a cons whose cdr is an alist. It&amp;rsquo;s done like this so storing works in general (think about empty alists).&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(defun make-wrapped-alist (&amp;amp;optional (for-alist '()))
  (cons nil for-alist))

(defun wrapped-alist-alist (wa)
  (cdr wa))

(defun wav (item wrapped-alist &amp;amp;key (test nil testp) (default nil))
  (let ((found (if testp
                   (assoc item (cdr wrapped-alist) :test test)
                 (assoc item (cdr wrapped-alist)))))
    (if found
        (values (cdr found) t)
      (values default nil))))

(defun (setf wav) (new item wrapped-alist &amp;amp;key (test nil testp) default)
  (declare (ignore default))
  (let ((found (if testp
                   (assoc item (cdr wrapped-alist) :test test)
                 (assoc item (cdr wrapped-alist)))))
    (if found
        (setf (cdr found) new)
      (progn
        (push (cons item new) (cdr wrapped-alist))
        new))))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I will use these wrapped alist places in the examples below.&lt;/p&gt;

&lt;h2 id="defaulting-places"&gt;Defaulting places&lt;/h2&gt;

&lt;p&gt;Quite often, a place has a default value or a way of indicating that there is no value in it, and you want to be able to say &amp;lsquo;if this place has not been stored into, then store this into it&amp;rsquo;. In the case of hash tables, the indicator is that &lt;code&gt;gethash&lt;/code&gt; returns a second value of &lt;code&gt;nil&lt;/code&gt;, and that is the same for &lt;code&gt;av&lt;/code&gt; and my wrapped alists.&lt;/p&gt;

&lt;p&gt;Sometimes this is not a problem, especially when the accessor for a place lets you provide a default:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(defun symbol-counts (l)
  (let ((table (make-hash-table)))
    (dolist (e l)
      (when (symbolp e)
        (incf (gethash e table 0))))
    (collecting
      (maphash (lambda (k v)
                 (collect (cons k v)))
               table))))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(defun symbol-counts/probably-slower (l)
  (let ((wa (make-wrapped-alist)))
    (dolist (e l)
      (when (symbolp e)
        (incf (av e wa :default 0))))
    (wrapped-alist-alist wa)))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But sometimes it is a problem. Consider the case where the fallback thing you want to store is expensive, or has side-effects. Now you need to write some boilerplate code:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(unless (nth-value 1 (wav item wa)
    (setf (wav item wa) (compute-complicated-thing))))&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id="the-wrong-way"&gt;The wrong way&lt;/h2&gt;

&lt;p&gt;Well, boilerplate is bad. So you might want to replace this by a macro:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(defmacro defaulting/wrong (place-form value-form)
  ;; This just assumes that PLACE-FORM returns NIL if it has no value:
  ;; in real life you need to be cleverer.
  `(or ,place-form
       (setf ,place-form ,value-form)))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is not only limited, but incorrect. It&amp;rsquo;s incorrect because it multiply evaluates subforms to &lt;code&gt;place-form&lt;/code&gt;. Consider this:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(let ((i 0) (table (make-hash-table)))
  (defaulting/wrong (gethash (incf i) table) 3))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Well, using wrapped alists it&amp;rsquo;s easy to see what this is doing wrong:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;&amp;gt; (let ((i 0) (wa (make-wrapped-alist)))
    (defaulting/wrong (wav (incf i) wa) 3)
    (wrapped-alist-alist wa))
((2 . 3))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So, not great. The boilerplate you&amp;rsquo;d need to write is:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;&amp;gt; (let ((i 0) (wa (make-wrapped-alist)))
    (let ((k (incf i)))
      (unless (wav k wa)
        (setf (wav k wa) 3)))
    (wrapped-alist-alist wa))
((1 . 3))&lt;/code&gt;&lt;/pre&gt;

&lt;h2 id="the-right-way"&gt;The right way&lt;/h2&gt;

&lt;p&gt;The problem is that any such &lt;code&gt;defaulting&lt;/code&gt; macro doesn&amp;rsquo;t know anything about the place it&amp;rsquo;s defaulting. So it can&amp;rsquo;t know which subforms of the place it needs to stash values for.&lt;/p&gt;

&lt;p&gt;Well, it turns out that the designers of CL thought of this, and they provided the tool you need, which is &lt;a href="https://www.lispworks.com/documentation/HyperSpec/Body/f_get_se.htm" title="get-setf-expansion"&gt;&lt;code&gt;get-setf-expansion&lt;/code&gt;&lt;/a&gt;. Given a place and optionally an environment, this will tell you exactly what you need to know to both read from that place and write to it, and to do so multiple times if need be.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;get-setf-expansion&lt;/code&gt; is what you need to be able to write your own &lt;code&gt;setf&lt;/code&gt;:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(defmacro assign (&amp;amp;rest pairs &amp;amp;environment e)
  ;; This should be SETF give or take
  `(progn
     ,@(collecting
         (for ((tail (on-list pairs :by #'cddr)))
           (destructuring-bind (place-form value-form . _) tail
             (declare (ignore _))
             (multiple-value-bind (vars vals store-vars writer-form reader-form)
                 (get-setf-expansion place-form e)
               (declare (ignore reader-form))
               (collect
                `(let* ,(mapcar #'list vars vals)
                   (multiple-value-bind ,store-vars ,value-form
                     ,writer-form)))))))))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But you can also use it to write &lt;code&gt;defaulting&lt;/code&gt; properly. Here is a much fancier version of it, which is now correct (I hope):&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;(defmacro defaulting (place value-form
                            &amp;amp;body options
                            &amp;amp;key test default-value nth-value &amp;amp;environment e)
  (declare (ignore options))            ;just for indent
  (multiple-value-bind (tvars tforms store-variables storing-form accessing-form)
      (get-setf-expansion place e)
    `(let* ,(mapcar #'list tvars tforms)
         (when ,(cond
                 ((and test nth-value)
                  `(not (funcall ,test ,default-value (nth-value ,nth-value ,accessing-form))))
                 (test
                  `(not (multiple-value-call ,test ,default-value ,accessing-form)))
                 ((and default-value nth-value)
                  `(eql ,default-value (nth-value ,nth-value ,accessing-form)))
                 (default-value
                  `(eql ,default-value ,accessing-form))
                 (nth-value
                  `(not (nth-value ,nth-value ,accessing-form)))
                 (t
                  `(not ,accessing-form)))
           (multiple-value-bind ,store-variables ,value-form
             ,storing-form))
         ,accessing-form)))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So now:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;&amp;gt; (let ((i 0) (wa (make-wrapped-alist)))
    (defaulting (wav (incf i) wa) 3)
    (wrapped-alist-alist wa))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Or, using options to this &lt;code&gt;defaulting&lt;/code&gt; to tell it the value to be checked:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;&amp;gt; (let ((i 0) (wa (make-wrapped-alist)))
    (defaulting (wav (incf i) wa) 3 :nth-value 1)
    (wrapped-alist-alist wa))
((1 . 3))&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Finally, you can see the expansion using &lt;a href="https://tfeb.org/fragments/documentation/tfeb-lisp-hax.html#tracing-macroexpansion-trace-macroexpand"&gt;&lt;code&gt;trace-macroexpand&lt;/code&gt;&lt;/a&gt;:&lt;/p&gt;

&lt;pre class="brush: lisp"&gt;&lt;code&gt;&amp;gt; (let ((a (make-wrapped-alist)))
    (defaulting (wav 'k a) 3 :nth-value 1))
(defaulting (wav 'k a)
    3
  :nth-value 1)
 -&amp;gt; (let* ((#:a1 a))
      (when (not (nth-value 1 (wav 'k #:a1)))
        (multiple-value-bind (#:new0) 3 (funcall #'(setf wav) #:new0 'k #:a1)))
      (wav 'k #:a1))
3
t&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and this is obviously correct.&lt;/p&gt;

&lt;p&gt;This macro exists in &lt;a href="https://tfeb.org/fragments/documentation/tfeb-lisp-hax.html#small-utilities-utilities" title="Small utilities"&gt;&lt;code&gt;org.tfeb.hax.utilities&lt;/code&gt;&lt;/a&gt;, the git repo for which is &lt;a href="https://tfeb.org/computer/repos/tfeb-lisp-hax.git" title="TFEB Lisp hax"&gt;&lt;code&gt;tfeb.org/computer/repos/tfeb-lisp-hax.git&lt;/code&gt;&lt;/a&gt;. Note it is &lt;em&gt;not&lt;/em&gt; in the archived GitHub repo.&lt;/p&gt;

&lt;p&gt;This is version 10.7.0 of the TFEB.ORG Lisp hax.&lt;/p&gt;</content></entry></feed>