<story><title>Emacs Lisp Readable Closures (2013)</title><url>https://nullprogram.com/blog/2013/12/30/</url></story><parent_chain></parent_chain><comment><author>TeMPOraL</author><text>For comparison, since I&amp;#x27;m using Emacs with native-compilation:&lt;p&gt;Interpreted result:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  ELISP&amp;gt; (hn&amp;#x2F;foo :bar :ignored)

  (closure
   ((y . :ignored)
    (x . :bar)
    t)
   nil x)
&lt;/code&gt;&lt;/pre&gt;
This is equivalent to the output in the article. Now, after running compile-defun on the function and calling it, I get:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  ELISP&amp;gt; (hn&amp;#x2F;foo :bar :ignored)

  #f(compiled-function
     ()
     #&amp;lt;bytecode 0x1f40000a8a1d&amp;gt;)
&lt;/code&gt;&lt;/pre&gt;
This is the &lt;i&gt;byte-compiled&lt;/i&gt; case, which sadly is not readable for some reason. That said, IELM (Elisp REPL) makes that #&amp;lt;bytecode ...&amp;gt; form clickable (it&amp;#x27;s a so-called &amp;quot;presentation&amp;quot;), which leads straight to the following disassembly:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  byte code:
    args: nil
  0       varref x
  1       return
&lt;/code&gt;&lt;/pre&gt;
After native-compiling via (load (native-compile &amp;quot;file.el&amp;quot;)), I get the same output as with byte-compiled case (+&amp;#x2F;- the address in #&amp;lt;bytecode ...&amp;gt; form), but the disassembly is slightly different:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  byte code:
    args: nil
  0       constant :bar
  1       return
&lt;/code&gt;&lt;/pre&gt;
EDIT: turns out it&amp;#x27;s IELM that&amp;#x27;s playing games with the printer. If I write:&lt;p&gt;&lt;pre&gt;&lt;code&gt;  (print (hn&amp;#x2F;foo :bar :ignored))
&lt;/code&gt;&lt;/pre&gt;
instead, I get the readable output from the article, in &lt;i&gt;both&lt;/i&gt; byte and native-compiled cases. My understanding of the latter is, the closure returned from a native-compiled function is itself only byte-compiled (at least when used in REPL), and the difference in bytecode assembly come from the latter running through a more thorough optimization process.</text></comment>
<story><title>Emacs Lisp Readable Closures (2013)</title><url>https://nullprogram.com/blog/2013/12/30/</url></story><parent_chain></parent_chain><comment><author>raspasov</author><text>Even though not part of the language, Clojure can do this via a library like &lt;a href=&quot;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;technomancy&amp;#x2F;serializable-fn&quot; rel=&quot;nofollow&quot;&gt;https:&amp;#x2F;&amp;#x2F;github.com&amp;#x2F;technomancy&amp;#x2F;serializable-fn&lt;/a&gt; (I just learned about this).</text></comment>