Skip to content

Commit fb04504

Browse files
author
Quarto GHA Workflow Runner
committed
Built site for gh-pages
1 parent 1bd7848 commit fb04504

13 files changed

Lines changed: 2464 additions & 149 deletions

File tree

.nojekyll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0cc0ed47
1+
94668fcf

clojure+/print/objects_and_protocols.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -395,20 +395,20 @@ <h1 class="title">Printing Objects and Protocols in Clojure</h1>
395395
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> (<span class="va">#'clojure.core/print-object</span> x w))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
396396
</div>
397397
<div class="printedClojure">
398-
<div class="sourceCode" id="cb2"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.lang.MultiFn <span class="bn">0x1879ba15</span> <span class="st">"clojure.lang.MultiFn@1879ba15"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
398+
<div class="sourceCode" id="cb2"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.lang.MultiFn <span class="bn">0xfaba0e3</span> <span class="st">"clojure.lang.MultiFn@faba0e3"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
399399
</div>
400400
<div class="sourceClojure">
401401
<div class="sourceCode" id="cb3"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>(Object.)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
402402
</div>
403403
<div class="printedClojure">
404-
<div class="sourceCode" id="cb4"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>#object[java.lang.Object <span class="bn">0x5c48a7ca</span> <span class="st">"java.lang.Object@5c48a7ca"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
404+
<div class="sourceCode" id="cb4"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>#object[java.lang.Object <span class="bn">0x75d257b8</span> <span class="st">"java.lang.Object@75d257b8"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
405405
</div>
406406
<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>. This can get pretty ugly:</p>
407407
<div class="sourceClojure">
408408
<div class="sourceCode" id="cb5"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>(async/chan)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
409409
</div>
410410
<div class="printedClojure">
411-
<div class="sourceCode" id="cb6"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.core.async.impl.channels.ManyToManyChannel <span class="bn">0x7a942e34</span> <span class="st">"clojure.core.async.impl.channels.ManyToManyChannel@7a942e34"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
411+
<div class="sourceCode" id="cb6"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.core.async.impl.channels.ManyToManyChannel <span class="bn">0x4723888b</span> <span class="st">"clojure.core.async.impl.channels.ManyToManyChannel@4723888b"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
412412
</div>
413413
<p><a href="https://github.com/tonsky/clojure-plus">clojure-plus</a> provides print-methods to improve printing many things.</p>
414414
<div class="sourceClojure">
@@ -447,7 +447,7 @@ <h1 class="title">Printing Objects and Protocols in Clojure</h1>
447447
<span id="cb14-3"><a href="#cb14-3" aria-hidden="true" tabindex="-1"></a> (.getName))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
448448
</div>
449449
<div class="printedClojure">
450-
<div class="sourceCode" id="cb15"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="st">"clojure_PLUS_.print.objects_and_protocols$eval72596$_PERCENT__PERCENT___72597$_PERCENT__PERCENT__PERCENT___72598"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
450+
<div class="sourceCode" id="cb15"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb15-1"><a href="#cb15-1" aria-hidden="true" tabindex="-1"></a><span class="st">"clojure_PLUS_.print.objects_and_protocols$eval72683$_PERCENT__PERCENT___72684$_PERCENT__PERCENT__PERCENT___72685"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
451451
</div>
452452
<p>Whoa, that’s pretty gross. We’d prefer to demunge the names at least.</p>
453453
<div class="sourceClojure">
@@ -460,7 +460,7 @@ <h1 class="title">Printing Objects and Protocols in Clojure</h1>
460460
<span id="cb17-2"><a href="#cb17-2" aria-hidden="true" tabindex="-1"></a> (class-name))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
461461
</div>
462462
<div class="printedClojure">
463-
<div class="sourceCode" id="cb18"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="st">"clojure+.print.objects-and-protocols/eval72603/%%--72604/%%%--72605"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
463+
<div class="sourceCode" id="cb18"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb18-1"><a href="#cb18-1" aria-hidden="true" tabindex="-1"></a><span class="st">"clojure+.print.objects-and-protocols/eval72690/%%--72691/%%%--72692"</span></span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
464464
</div>
465465
<p>Notice the <code>/evalNNNNN/</code> part? To create a function, Clojure creates a new class. The <code>/evalNNNNN/</code> counts every time it evaluates. This is useful in the sense that it identifies the class for that evaluation. But we almost never care for that detail (more on that later). For the same reason our strangely named functions have <code>--NNNNN</code> appended to them, because they are sub evaluations of the top-level evaluation.</p>
466466
<p>Let’s do away with that noise for the moment:</p>

clojure/print_object/remove_extraneous.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,20 +401,20 @@ <h1 class="title">Clean object printing by removing extraneous</h1>
401401
<span id="cb1-2"><a href="#cb1-2" aria-hidden="true" tabindex="-1"></a> (<span class="va">#'clojure.core/print-object</span> x w))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
402402
</div>
403403
<div class="printedClojure">
404-
<div class="sourceCode" id="cb2"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.lang.MultiFn <span class="bn">0x1879ba15</span> <span class="st">"clojure.lang.MultiFn@1879ba15"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
404+
<div class="sourceCode" id="cb2"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb2-1"><a href="#cb2-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.lang.MultiFn <span class="bn">0xfaba0e3</span> <span class="st">"clojure.lang.MultiFn@faba0e3"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
405405
</div>
406406
<div class="sourceClojure">
407407
<div class="sourceCode" id="cb3"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb3-1"><a href="#cb3-1" aria-hidden="true" tabindex="-1"></a>(Object.)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
408408
</div>
409409
<div class="printedClojure">
410-
<div class="sourceCode" id="cb4"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>#object[java.lang.Object <span class="bn">0x6a2cc246</span> <span class="st">"java.lang.Object@6a2cc246"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
410+
<div class="sourceCode" id="cb4"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb4-1"><a href="#cb4-1" aria-hidden="true" tabindex="-1"></a>#object[java.lang.Object <span class="bn">0x2990a142</span> <span class="st">"java.lang.Object@2990a142"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
411411
</div>
412412
<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>
413413
<div class="sourceClojure">
414414
<div class="sourceCode" id="cb5"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb5-1"><a href="#cb5-1" aria-hidden="true" tabindex="-1"></a>(async/chan)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
415415
</div>
416416
<div class="printedClojure">
417-
<div class="sourceCode" id="cb6"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.core.async.impl.channels.ManyToManyChannel <span class="bn">0x77dd28e3</span> <span class="st">"clojure.core.async.impl.channels.ManyToManyChannel@77dd28e3"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
417+
<div class="sourceCode" id="cb6"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb6-1"><a href="#cb6-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.core.async.impl.channels.ManyToManyChannel <span class="bn">0x1879ba15</span> <span class="st">"clojure.core.async.impl.channels.ManyToManyChannel@1879ba15"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
418418
</div>
419419
<div class="quarto-figure quarto-figure-center">
420420
<figure class="figure">
@@ -427,14 +427,14 @@ <h1 class="title">Clean object printing by removing extraneous</h1>
427427
<div class="sourceCode" id="cb7"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb7-1"><a href="#cb7-1" aria-hidden="true" tabindex="-1"></a>(<span class="kw">fn</span> [x] x)</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
428428
</div>
429429
<div class="printedClojure">
430-
<div class="sourceCode" id="cb8"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.print_object.remove_extraneous$eval72467$fn__72468 <span class="bn">0x686a8e6a</span> <span class="st">"clojure.print_object.remove_extraneous$eval72467$fn__72468@686a8e6a"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
430+
<div class="sourceCode" id="cb8"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb8-1"><a href="#cb8-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.print_object.remove_extraneous$eval72467$fn__72468 <span class="bn">0x174abee5</span> <span class="st">"clojure.print_object.remove_extraneous$eval72467$fn__72468@174abee5"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
431431
</div>
432432
<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 <a href="../../code_interview/beating/with_stupid_stuff/z_combinator_gambit.html">odd lambda calculus excursion</a>, things get even more hectic.</p>
433433
<div class="sourceClojure">
434434
<div class="sourceCode" id="cb9"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb9-1"><a href="#cb9-1" aria-hidden="true" tabindex="-1"></a>((<span class="kw">fn</span> [x] (<span class="kw">fn</span> [v] ((x x) v))) (<span class="kw">fn</span> [y] y))</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
435435
</div>
436436
<div class="printedClojure">
437-
<div class="sourceCode" id="cb10"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.print_object.remove_extraneous$eval72471$fn__72472$fn__72473 <span class="bn">0x7d9e2406</span> <span class="st">"clojure.print_object.remove_extraneous$eval72471$fn__72472$fn__72473@7d9e2406"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
437+
<div class="sourceCode" id="cb10"><pre class="sourceCode clojure code-with-copy"><code class="sourceCode clojure"><span id="cb10-1"><a href="#cb10-1" aria-hidden="true" tabindex="-1"></a>#object[clojure.print_object.remove_extraneous$eval72471$fn__72472$fn__72473 <span class="bn">0x29241a50</span> <span class="st">"clojure.print_object.remove_extraneous$eval72471$fn__72472$fn__72473@29241a50"</span>]</span></code><button title="Copy to Clipboard" class="code-copy-button"><i class="bi"></i></button></pre></div>
438438
</div>
439439
<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>
440440
<div class="sourceClojure">

code_interview/beating/with_stupid_stuff/z_combinator_gambit.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ <h1 class="title">The Z-Combinator Gambit</h1>
482482
<pre><code>
483483
#error {
484484
:class java.lang.ClassCastException
485-
:message "class code_interview.beating.with_stupid_stuff.z_combinator_gambit$REV_SINGLEQUOTE_$fn__45748 cannot be cast to class clojure.lang.IPersistentCollection (code_interview.beating.with_stupid_stuff.z_combinator_gambit$REV_SINGLEQUOTE_$fn__45748 is in unnamed module of loader clojure.lang.DynamicClassLoader @724c004b; clojure.lang.IPersistentCollection is in unnamed module of loader 'app')"
485+
:message "class code_interview.beating.with_stupid_stuff.z_combinator_gambit$REV_SINGLEQUOTE_$fn__45748 cannot be cast to class clojure.lang.IPersistentCollection (code_interview.beating.with_stupid_stuff.z_combinator_gambit$REV_SINGLEQUOTE_$fn__45748 is in unnamed module of loader clojure.lang.DynamicClassLoader @6f2399bf; clojure.lang.IPersistentCollection is in unnamed module of loader 'app')"
486486
:trace
487487
[[clojure.core/conj "core.clj" 84]
488488
[code-interview.beating.with-stupid-stuff.z-combinator-gambit/REV'/fn]
@@ -617,7 +617,7 @@ <h1 class="title">The Z-Combinator Gambit</h1>
617617
<pre><code>
618618
#error {
619619
:class java.lang.ClassCastException
620-
:message "class code_interview.beating.with_stupid_stuff.z_combinator_gambit$REV_LOGIC$fn__45758 cannot be cast to class clojure.lang.IPersistentCollection (code_interview.beating.with_stupid_stuff.z_combinator_gambit$REV_LOGIC$fn__45758 is in unnamed module of loader clojure.lang.DynamicClassLoader @142a3b4b; clojure.lang.IPersistentCollection is in unnamed module of loader 'app')"
620+
:message "class code_interview.beating.with_stupid_stuff.z_combinator_gambit$REV_LOGIC$fn__45758 cannot be cast to class clojure.lang.IPersistentCollection (code_interview.beating.with_stupid_stuff.z_combinator_gambit$REV_LOGIC$fn__45758 is in unnamed module of loader clojure.lang.DynamicClassLoader @36559157; clojure.lang.IPersistentCollection is in unnamed module of loader 'app')"
621621
:trace
622622
[[clojure.core/conj "core.clj" 84]
623623
[code-interview.beating.with-stupid-stuff.z-combinator-gambit/REV-LOGIC/fn]

0 commit comments

Comments
 (0)