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
Copy file name to clipboardExpand all lines: clojure+/print/objects_and_protocols.html
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -400,20 +400,20 @@ <h1 class="title">Printing Objects and Protocols in Clojure</h1>
400
400
<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>. This can get pretty ugly:</p>
412
412
<divclass="sourceClojure">
413
413
<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>
<p><ahref="https://github.com/tonsky/clojure-plus">clojure-plus</a> provides print-methods to improve printing many things.</p>
419
419
<divclass="sourceClojure">
@@ -452,7 +452,7 @@ <h1 class="title">Printing Objects and Protocols in Clojure</h1>
452
452
<spanid="cb14-3"><ahref="#cb14-3" aria-hidden="true" tabindex="-1"></a> (.getName))</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
453
453
</div>
454
454
<divclass="printedClojure">
455
-
<divclass="sourceCode" id="cb15"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb15-1"><ahref="#cb15-1" aria-hidden="true" tabindex="-1"></a><spanclass="st">"clojure_PLUS_.print.objects_and_protocols$eval72686$_PERCENT__PERCENT___72687$_PERCENT__PERCENT__PERCENT___72688"</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
455
+
<divclass="sourceCode" id="cb15"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb15-1"><ahref="#cb15-1" aria-hidden="true" tabindex="-1"></a><spanclass="st">"clojure_PLUS_.print.objects_and_protocols$eval72733$_PERCENT__PERCENT___72734$_PERCENT__PERCENT__PERCENT___72735"</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
456
456
</div>
457
457
<p>Whoa, that’s pretty gross. We’d prefer to demunge the names at least.</p>
458
458
<divclass="sourceClojure">
@@ -465,7 +465,7 @@ <h1 class="title">Printing Objects and Protocols in Clojure</h1>
465
465
<spanid="cb17-2"><ahref="#cb17-2" aria-hidden="true" tabindex="-1"></a> (class-name))</span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
466
466
</div>
467
467
<divclass="printedClojure">
468
-
<divclass="sourceCode" id="cb18"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb18-1"><ahref="#cb18-1" aria-hidden="true" tabindex="-1"></a><spanclass="st">"clojure+.print.objects-and-protocols/eval72693/%%--72694/%%%--72695"</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
468
+
<divclass="sourceCode" id="cb18"><preclass="sourceCode clojure code-with-copy"><codeclass="sourceCode clojure"><spanid="cb18-1"><ahref="#cb18-1" aria-hidden="true" tabindex="-1"></a><spanclass="st">"clojure+.print.objects-and-protocols/eval72740/%%--72741/%%%--72742"</span></span></code><buttontitle="Copy to Clipboard" class="code-copy-button"><iclass="bi"></i></button></pre></div>
469
469
</div>
470
470
<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>
471
471
<p>Let’s do away with that noise for the moment:</p>
0 commit comments