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
+7-7Lines changed: 7 additions & 7 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>Hmmmm. not so nice. We’ll dig into this further below. But we also need to be aware that Clojure munges it’s names to make Java valid names. This matters for some things:</p>
449
449
<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$eval70667$_PERCENT__PERCENT___70668$_PERCENT__PERCENT__PERCENT___70669"</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$eval70694$_PERCENT__PERCENT___70695$_PERCENT__PERCENT__PERCENT___70696"</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/eval70674/%%--70675/%%%--70676"</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/eval70701/%%--70702/%%%--70703"</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>
@@ -766,7 +766,7 @@ <h1 class="title">Printing Objects and Protocols in Clojure</h1>
0 commit comments