6 lines
2.1 KiB
Plaintext
6 lines
2.1 KiB
Plaintext
<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 didn’t make sense to you, Kitchin’s video explains it all. If you’re familiar with any of the Lisp dialects, you’ll also be familiar with <code>let</code>. It turns out, though, that there’s still a bit to learn. Elisp has additional let constructs that are reminiscent of Common Lisp’s <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>, it’s 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. It’s much more complex than the others so Kitchin doesn’t discuss it in depth.</p>
|
||
<p>This is a short video, 12 minutes, 12 seconds, but it’s 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> |