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

Correct wording: easier understand -> easier to understand #217

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
2 changes: 1 addition & 1 deletion content/cftbat/read-and-eval.html
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ <h3>Syntactic Abstraction and the -&gt; Macro</h3>
</code></pre></div></div>

<p class="Body"><span>You can read this as a pipeline that goes from top to bottom instead of from inner parentheses to outer parentheses. First, </span><code>path</code><span> gets passed to </span><code>io/</code><code>resource</code>, then the result gets passed to <code>slurp</code>, and finally the result of that gets passed to <code>read-string</code>.</p>
<p class="Body"><span>These two ways of defining </span><code>read-resource</code><span> are entirely equivalent. However, the second one might be easier understand because we can </span>approach it from top to bottom, a direction we’re used to. The <code>-&gt;</code> also lets us omit parentheses, which means there’s less visual noise to contend with. This is a <em>syntactic abstraction</em> because it lets you write code in a syntax that’s different from Clojure’s built-in syntax but is preferable for human consumption. Better than lead into gold!!!</p>
<p class="Body"><span>These two ways of defining </span><code>read-resource</code><span> are entirely equivalent. However, the second one might be easier to understand because we can </span>approach it from top to bottom, a direction we’re used to. The <code>-&gt;</code> also lets us omit parentheses, which means there’s less visual noise to contend with. This is a <em>syntactic abstraction</em> because it lets you write code in a syntax that’s different from Clojure’s built-in syntax but is preferable for human consumption. Better than lead into gold!!!</p>
<h2>Summary</h2>
<p class="BodyFirst">In this chapter, you learned about Clojure’s evaluation process. First, the reader transforms text into Clojure data structures. Next, the macro expander transforms those data structures with macros, converting your custom syntax into syntactically valid data structures. Finally, those data structures get sent to the evaluator. The evaluator processes data structures based on their type: symbols are resolved to their referents; lists result in function, macro, or special form calls; and everything else evaluates to itself.</p>
<p class="Body">The coolest thing about this process is that it allows you to use Clojure to expand its own syntax. This process is made easier because Clojure is homoiconic: its text represents data structures, and those data structures represent abstract syntax trees, allowing you to more easily reason about how to construct syntax-expanding macros.</p>
Expand Down