You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<spanid="cb1-2"><ahref="#cb1-2" aria-hidden="true" tabindex="-1"></a> (<spanclass="va">#'clojure.core/print-object</span> x w))</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
<p>The syntax is <code>#object[CLASS-NAME HASH toString())]</code> and as you can see, the toString of an Object is <code>CLASS-NAME@HASH</code>. For most objects this becomes quite a long string.</p>
413
413
<divclass="sourceClojure">
414
414
<divclass="sourceCode" id="cb5"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb5-1"><ahref="#cb5-1" aria-hidden="true" tabindex="-1"></a>(async/chan)</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
<divclass="sourceCode" id="cb8"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb8-1"><ahref="#cb8-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.print_object.remove_extraneous$eval72407$fn__72408<spanclass="bn">0x7268ea42</span><spanclass="st">"clojure.print_object.remove_extraneous$eval72407$fn__72408@7268ea42"</span>]</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
430
+
<divclass="sourceCode" id="cb8"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb8-1"><ahref="#cb8-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.print_object.remove_extraneous$eval72426$fn__72427<spanclass="bn">0x79cca0dc</span><spanclass="st">"clojure.print_object.remove_extraneous$eval72426$fn__72427@79cca0dc"</span>]</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
431
431
</div>
432
432
<p>It’s quite easy to miss the fact that it is a function as we are looking for a tiny little <code>fn</code> in a sea of text. If, like me, you are fond of the <ahref="../../code_interview/beating/with_stupid_stuff/z_combinator_gambit.html">odd lambda calculus excursion</a>, things get even more hectic.</p>
<divclass="sourceCode" id="cb10"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb10-1"><ahref="#cb10-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.print_object.remove_extraneous$eval72411$fn__72412$fn__72413<spanclass="bn">0xcb49434</span><spanclass="st">"clojure.print_object.remove_extraneous$eval72411$fn__72412$fn__72413@cb49434"</span>]</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
437
+
<divclass="sourceCode" id="cb10"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb10-1"><ahref="#cb10-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.print_object.remove_extraneous$eval72430$fn__72431$fn__72432<spanclass="bn">0x234ea269</span><spanclass="st">"clojure.print_object.remove_extraneous$eval72430$fn__72431$fn__72432@234ea269"</span>]</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
438
438
</div>
439
439
<p>Yikes! what an eyesore. This is not an academic issue specific to lambda calculus. Any function created from inside a function is helpfully identifiable through the <code>fn$fn</code> nesting. We create these quite regularly, and they are often printed in stack traces. I’m sure you have seen them when you map an inline function across a seq, and there is a bug in the anonymous function.</p>
<spanid="cb13-4"><ahref="#cb13-4" aria-hidden="true" tabindex="-1"></a> [clojure.core$mapv$fn__8565 invoke <spanclass="st">"core.clj"</span><spanclass="dv">7059</span>]]</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
454
454
</div>
455
455
<p>See that part <code>caesar_cipher$add2</code>? That is <strong>very</strong> useful information. It tells us that the exception was inside <code>add2</code>, which is inside <code>caesar-cipher</code>. The stack trace doesn’t print functions as objects, but it illustrates that the thing that we care about is that they are a function, what their name is, and whether they were created from inside another function.</p>
<divclass="sourceCode" id="cb24"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb24-1"><ahref="#cb24-1" aria-hidden="true" tabindex="-1"></a><spanclass="st">"Wrong number of args (1) passed to: clojure.transducers.what-if/eval72343/fn--72344"</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
481
+
<divclass="sourceCode" id="cb24"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb24-1"><ahref="#cb24-1" aria-hidden="true" tabindex="-1"></a><spanclass="st">"Wrong number of args (1) passed to: clojure.transducers.what-if/eval72362/fn--72363"</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
482
482
</div>
483
483
<p>Why is it trying to call <code>cons</code> with a single argument? In addition to separating the transformation from the output, <code>transduce</code> also has a “completion” step, which is performed on the final result. A convenience function called <code>completing</code> can be used to wrap the function here to provide a “no-op” completion:</p>
0 commit comments