aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2015-03-02 21:30:10 -0600
committerJoel Martin <github@martintribe.org>2015-03-02 21:30:10 -0600
commit8a98ef9a3f3a6b6d05d02dc305a0c886c907e0f3 (patch)
tree2d8c42fbaa855701df39d3dbfc6997cc1aeefa0f
parentb52c54b9ed49d0c2d4a9747fff0d0fe15c9f230a (diff)
downloadmal-8a98ef9a3f3a6b6d05d02dc305a0c886c907e0f3.tar.gz
mal-8a98ef9a3f3a6b6d05d02dc305a0c886c907e0f3.zip
process/guide.md: add some step8 wrapup text.
-rw-r--r--process/guide.md31
1 files changed, 31 insertions, 0 deletions
diff --git a/process/guide.md b/process/guide.md
index 440a4de..ef5e33d 100644
--- a/process/guide.md
+++ b/process/guide.md
@@ -1110,6 +1110,37 @@ Now go to the top level, run the step 8 tests:
make test^quux^step8
```
+There is a reasonably good chance that the macro tests will not pass
+the first time. Although the implementation of macros is fairly
+simple, debugging runtime bugs with macros can be fairly tricky. If
+you do run into subtle problems that are difficult to solve, let me
+recommend a couple of approaches:
+
+* Use the macroexpand special form to eliminate one of the layers of
+ indirection (to expand but skip evaluate). This will often reveal
+ the source of the issue.
+* Add a debug print statement to the top of your main `eval` function
+ (inside the TCO loop) to print the current value of `ast` (hint use
+ `pr_str` to get easier to debug output). Pull up the step8
+ implementation from another language and uncomment its `eval`
+ function (yes, I give you permission to violate the rule this once).
+ Run the two side-by-side. The first difference is likely to point to
+ the bug.
+
+Congratulations! You now have a Lisp interpreter with a super power
+that most non-Lisp languages can only dream of (I have it on good
+authority that languages dream when you are not using them). If you
+are not already familiar with Lisp macros, I suggest the following
+excercise: write a recursive macro that handles postfixed mal code
+(with the function as the last parameter instead of the first). Or
+not. I have not actually done so myself, but I have heard it is an
+interesting excercise.
+
+In the next step you will add try/catch style exception handling to
+your implementation in addition to some new core functions. After
+step9 you will be very close to having a fully self-hosting mal
+implementation. Let us continue!
+
### Optional