emacs/var/elfeed/db/data/68/68e8890309e39ddfa9d3d924c5588d46194a5e4f
2022-01-03 12:49:32 -06:00

6 lines
2.1 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>John Kitchin has a short video in his <a href="https://www.youtube.com/playlist?list=PL0sMmOaE_gs3E0OjExoI7vlCAVygj6S4I">Scimax channel</a> that considers another Elisp construct. This video talks about <a href="https://www.youtube.com/watch?v=KQnVi7Pks4c">let and its siblings</a>. One of the first non-trivial things a new Lisper learns is how to deal with local variables using <code>let</code>.</p>
<p>If that didnt make sense to you, Kitchins video explains it all. If youre familiar with any of the Lisp dialects, youll also be familiar with <code>let</code>. It turns out, though, that theres still a bit to learn. Elisp has additional let constructs that are reminiscent of Common Lisps <a href="http://www.lispworks.com/documentation/HyperSpec/Body/m_destru.htm">destructuring-bind</a>.</p>
<p>The first, <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Association-Lists.html#index-let_002dalist">let-alist</a>, binds each <code>car</code> of an <code>alist</code> to its corresponding <code>cdr</code>. If you have to deal with several entries in an <code>alist</code>, its a way of referring to an <code>alist</code> value by name instead of the normal <code>assoc/car/cdr</code> dance.</p>
<p>The second, <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Sequence-Functions.html#index-seq_002dlet">seq-let</a>, is similar except that it takes two lists. The first is a list of symbols that are bound to the corresponding items in the second list. This is basically a scaled down version <code>destructuring-bind</code>.</p>
<p>Finally, Kitchin mentions <a href="https://www.gnu.org/software/emacs/manual/html_node/elisp/Destructuring-with-pcase-Patterns.html#index-pcase_002dlet">pcase-let</a>, which binds patterns to values. Its much more complex than the others so Kitchin doesnt discuss it in depth.</p>
<p>This is a short video, 12 minutes, 12 seconds, but its really useful for Elisp n00bs and those not familiar with <code>let-alist</code>, <code>seq-alist</code>, and <code>pcase-let</code>. If you fall into either category, be sure to take a look.</p>