From 092794cad65c043f629da14406935b6f258c5304 Mon Sep 17 00:00:00 2001 From: "Marius A. Rabenarivo" Date: Mon, 27 Sep 2021 13:28:01 +0400 Subject: [PATCH] Correct wording: easier understand -> easier to understand --- content/cftbat/read-and-eval.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/cftbat/read-and-eval.html b/content/cftbat/read-and-eval.html index 1556b38f..c3fc7ba6 100644 --- a/content/cftbat/read-and-eval.html +++ b/content/cftbat/read-and-eval.html @@ -377,7 +377,7 @@

Syntactic Abstraction and the -> Macro

You can read this as a pipeline that goes from top to bottom instead of from inner parentheses to outer parentheses. First, path gets passed to io/resource, then the result gets passed to slurp, and finally the result of that gets passed to read-string.

-

These two ways of defining read-resource are entirely equivalent. However, the second one might be easier understand because we can approach it from top to bottom, a direction we’re used to. The -> also lets us omit parentheses, which means there’s less visual noise to contend with. This is a syntactic abstraction 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!!!

+

These two ways of defining read-resource are entirely equivalent. However, the second one might be easier to understand because we can approach it from top to bottom, a direction we’re used to. The -> also lets us omit parentheses, which means there’s less visual noise to contend with. This is a syntactic abstraction 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!!!

Summary

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.

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.