Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 'macroexpand' output in Chapter 8 #180

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions content/cftbat/writing-macros.html
Original file line number Diff line number Diff line change
Expand Up @@ -589,11 +589,11 @@ <h3><a id="Anchor"></a>if-valid</h3>
<span class="tok-o">'</span><span class="tok-p">(</span><span class="tok-nf">if-valid</span> <span class="tok-nv">order-details</span> <span class="tok-nv">order-details-validations</span> <span class="tok-nv">my-error-name</span>
<span class="tok-p">(</span><span class="tok-nb">println </span><span class="tok-ss">:success</span><span class="tok-p">)</span>
<span class="tok-p">(</span><span class="tok-nb">println </span><span class="tok-ss">:failure</span> <span class="tok-nv">my-error-name</span><span class="tok-p">)))</span>
<span class="tok-p">(</span><span class="tok-nf">let*</span>
<span class="tok-p">[</span><span class="tok-nv">my-error-name</span> <span class="tok-p">(</span><span class="tok-nf">user/validate</span> <span class="tok-nv">order-details</span> <span class="tok-nv">order-details-validations</span><span class="tok-p">)]</span>
<span class="tok-p">(</span><span class="tok-k">if </span><span class="tok-p">(</span><span class="tok-nf">clojure.core/empty?</span> <span class="tok-nv">my-error-name</span><span class="tok-p">)</span>
<span class="tok-p">(</span><span class="tok-nb">println </span><span class="tok-ss">:success</span><span class="tok-p">)</span>
<span class="tok-p">(</span><span class="tok-nb">println </span><span class="tok-ss">:failure</span> <span class="tok-nv">my-error-name</span><span class="tok-p">)))</span>
<span class="tok-c1">; =&gt; (let*</span>
<span class="tok-c1">; =&gt; [my-error-name (user/validate order-details order-details-validations)]</span>
<span class="tok-c1">; =&gt; (if (clojure.core/empty? my-error-name)
<span class="tok-c1">; =&gt; (println :success)</span>
<span class="tok-c1">; =&gt; (println :failure my-error-name)))</span>
</code></pre></div></div>

<p class="Body"><span>The syntax quote abstracts the general form of the </span><code>let/validate/if </code><span>pattern you saw earlier. Then we use unquote splicing to unpack the </span><code>if</code><span> </span>branches, which were packed into the <code>then-else</code> rest argument.</p>
Expand Down