"Before I had studied Chan (Zen) for thirty years, I saw mountains as
mountains, and rivers as rivers. When I arrived at a more intimate
knowledge, I came to the point where I saw that mountains are not
mountains, and rivers are not rivers. But now that I have got its very
substance I am at rest. For it’s just that I see mountains once again
as mountains, and rivers once again as rivers"
–Buddhist saying originally formulated by Qingyuan Weixin,
later translated by D.T. Suzuki in his Essays in Zen
-Buddhism.
\ No newline at end of file
diff --git a/Our_plan_of_attack.html b/Our_plan_of_attack.html
index 4b3f347..576d3fd 100644
--- a/Our_plan_of_attack.html
+++ b/Our_plan_of_attack.html
@@ -1,5 +1,5 @@
-2 Our plan of attack
The macro system you will mostly want to use for production-quality
macros is called syntax-parse. And don’t worry, we’ll get to
that soon.
But if we start there, you’re likely to feel overwhelmed by concepts
and terminology, and get very confused. I did.
1. Instead let’s start with the basics: A syntax object and a function
@@ -19,4 +19,4 @@ they’re used in error. Normal Racket functions optionally can have
contracts and types. These catch usage mistakes and provide clear,
useful error messages. It would be great if there were something
similar for macro. There is. One of the more-recent Racket macro
-enhancements is syntax-parse.
\ No newline at end of file
diff --git a/Preface.html b/Preface.html
index b17932a..1a8d8ca 100644
--- a/Preface.html
+++ b/Preface.html
@@ -1,5 +1,5 @@
-1 Preface
I learned Racket after 25 years of mostly using C and C++.
Some psychic whiplash resulted.
"All the parentheses" was actually not a big deal. Instead, the first
mind warp was functional programming. Before long I wrapped my brain
around it, and went on to become comfortable and effective with many
other aspects and features of Racket.
But two final frontiers remained: Macros and continuations.
I found that simple macros were easy and understandable, plus there
@@ -21,4 +21,4 @@ problems or annoyances. I learn more quickly and deeply when I
discover the answer to a question I already have, or find the solution
to a problem whose pain I already feel. Therefore I’ll give you the
questions and problems first, so that you can better appreciate and
-understand the answers and solutions.
\ No newline at end of file
diff --git a/References_and_Acknowledgments.html b/References_and_Acknowledgments.html
index fca391e..ddac5b0 100644
--- a/References_and_Acknowledgments.html
+++ b/References_and_Acknowledgments.html
@@ -1,5 +1,5 @@
-8 References and Acknowledgments
Eli Barzilay’s blog post,
Writing
‘syntax-case’ Macros, helped me understand many key details and
concepts, and inspired me to use a "bottom-up" approach.
Eli wrote another blog post,
@@ -25,4 +25,4 @@ improved since I last read it. Of course, it was the same; I’d
changed. It’s interesting how much of what we already know is
projected between the lines. My point is, the Racket documentation is
very good. The Guide provides helpful examples and
-tutorials. The Reference is very clear and precise.
;I guess I goofed, but – what is this "string-append" of which you
;speak??
The problem is that the resulting error message will be confusing. Our
user thinks they’re calling misuse, but is getting an error
message from string-append. In this simple example they
could probably guess what’s happening, but in most cases they won’t.
;I goofed, and understand why! It's a shame the writer of the
;function had to work so hard to tell me.
Unfortunately the error code tends to overwhelm and/or obscure our
function definition. Also, the error message is good but not
-great. Improving it would require even more error code.
\ No newline at end of file
diff --git a/Syntax_parameters.html b/Syntax_parameters.html
index da13755..321d958 100644
--- a/Syntax_parameters.html
+++ b/Syntax_parameters.html
@@ -1,5 +1,5 @@
-5 Syntax parameters
cannot reference an identifier before its definition
in module: 'program
Wait, what? it is undefined?
It turns out that all along we have been protected from making a
certain kind of mistake in our macros. The mistake is if our new
@@ -22,4 +22,4 @@ value:
\ No newline at end of file
diff --git a/Transform_.html b/Transform_.html
index 68c9f42..1e51ed8 100644
--- a/Transform_.html
+++ b/Transform_.html
@@ -1,5 +1,5 @@
-3 Transform!
When we use define-syntax, we’re making a transformer
@@ -101,4 +101,4 @@ automatically. If we need other modules, we have to require them, and
do so for compile time using for-syntax.
Similarly, if we want to define helper functions in the same
file/module as the macros that use them, we need to wrap the
definitions inside a begin-for-syntax form. Doing so makes
-them available at compile time.
\ No newline at end of file
diff --git a/What_s_the_point_of_splicing-let_.html b/What_s_the_point_of_splicing-let_.html
index c226742..1b813d3 100644
--- a/What_s_the_point_of_splicing-let_.html
+++ b/What_s_the_point_of_splicing-let_.html
@@ -1,5 +1,5 @@
-6 What's the point of splicing-let?
\ No newline at end of file
diff --git a/all.html b/all.html
index e0fc1d5..aa27ae2 100644
--- a/all.html
+++ b/all.html
@@ -1,6 +1,6 @@
Fear of Macros
I learned Racket after 25 years of mostly using C and C++.
Some psychic whiplash resulted.
"All the parentheses" was actually not a big deal. Instead, the first
mind warp was functional programming. Before long I wrapped my brain
around it, and went on to become comfortable and effective with many
other aspects and features of Racket.
But two final frontiers remained: Macros and continuations.
I found that simple macros were easy and understandable, plus there
@@ -255,8 +255,8 @@ pieces.
If you write programs for web services you deal with JSON, which i
represented in Racket by a jsexpr?. JSON often has
dictionaries that contain other dictionaries. In a jsexpr?
these are represented by nested hasheq tables:
Not too bad. Of course, the version with error-checking is quite a bit
longer. Error-checking code generally tends to obscure the logic, and
does here. Fortunately we’ll soon see how syntax-parse can
help mitigate that, in much the same way as contracts in normal
@@ -301,7 +301,7 @@ user thinks they’re calling misuse, but is get
message from string-append. In this simple example they
could probably guess what’s happening, but in most cases they won’t.
;I goofed, and understand why! It's a shame the writer of the
;function had to work so hard to tell me.
Unfortunately the error code tends to overwhelm and/or obscure our
function definition. Also, the error message is good but not
-great. Improving it would require even more error code.
Even better, Typed Racket can catch usage mistakes up-front at compile
time.
7.2Error-handling strategies for macros
For macros, we have similar choices.
1. Ignore the possibility of misuse. This choice is even worse for
diff --git a/index.html b/index.html
index 7215111..73bf283 100644
--- a/index.html
+++ b/index.html
@@ -1,3 +1,3 @@
-
Most useful syntax transformers work by taking some input syntax, and
rearranging the pieces into something else. As we saw, this is
possible but tedious using list accessors such as
cadddr. It’s more convenient and less error-prone to use
@@ -110,12 +110,12 @@ pieces.
If you write programs for web services you deal with JSON, which i
represented in Racket by a jsexpr?. JSON often has
dictionaries that contain other dictionaries. In a jsexpr?
these are represented by nested hasheq tables:
Not too bad. Of course, the version with error-checking is quite a bit
longer. Error-checking code generally tends to obscure the logic, and
does here. Fortunately we’ll soon see how syntax-parse can
help mitigate that, in much the same way as contracts in normal
Racket or types in Typed Racket.
Maybe we’re not convinced that writing (hash.refsjs.a.b.c)
is really clearer than (hash-refsjs'(abc)). Maybe we
won’t actually use this approach. But the Racket macro system makes it
-a possible choice.