From 65fc5cedc586c571b41decb5fb6013089f6031c5 Mon Sep 17 00:00:00 2001
From: John Croisant <john@croisant.net>
Date: Sun, 11 Jul 2021 23:15:01 -0500
Subject: [PATCH 1/2] Add `expand1` procedure in module (chicken syntax).
Like `expand` but expands the form only once, instead of repeating
until a non-macro form is produced. This is helpful when debugging
macros because you can see the intermediate results of the expansion.
---
chicken.syntax.import.scm | 1 +
expand.scm | 4 ++++
manual/Module (chicken syntax) | 8 ++++++++
3 files changed, 13 insertions(+)
diff --git a/chicken.syntax.import.scm b/chicken.syntax.import.scm
index 13983816..da39de12 100644
a
|
b
|
|
31 | 31 | 'chicken.syntax |
32 | 32 | 'expand |
33 | 33 | '((expand . chicken.syntax#expand) |
| 34 | (expand1 . chicken.syntax#expand1) |
34 | 35 | (get-line-number . chicken.syntax#get-line-number) |
35 | 36 | (strip-syntax . chicken.syntax#strip-syntax) |
36 | 37 | (syntax-error . chicken.syntax#syntax-error) |
diff --git a/expand.scm b/expand.scm
index e815a2b9..e6dd57c4 100644
a
|
b
|
|
36 | 36 | |
37 | 37 | (module chicken.syntax |
38 | 38 | (expand |
| 39 | expand1 |
39 | 40 | get-line-number |
40 | 41 | strip-syntax |
41 | 42 | syntax-error |
… |
… |
|
305 | 306 | (loop exp2) |
306 | 307 | exp2) ) ) ) |
307 | 308 | |
| 309 | (define (expand1 exp #!optional (se (##sys#current-environment)) cs?) |
| 310 | (nth-value 0 (##sys#expand-0 exp se cs?)) ) |
| 311 | |
308 | 312 | |
309 | 313 | ;;; Extended (DSSSL-style) lambda lists |
310 | 314 | ; |
diff --git a/manual/Module (chicken syntax) b/manual/Module (chicken syntax)
index eaa7dbd1..ab169c9b 100644
a
|
b
|
comparison {{(compare sym 'abc)}} should be written as {{(compare sym |
301 | 301 | If {{X}} is a macro-form, expand the macro (and repeat expansion |
302 | 302 | until expression is a non-macro form). Returns the resulting expression. |
303 | 303 | |
| 304 | ==== expand1 |
| 305 | |
| 306 | <procedure>(expand1 X)</procedure> |
| 307 | |
| 308 | If {{X}} is a macro-form, expand the macro only once. Unlike |
| 309 | {{expand}}, does not repeat expansion when the resulting expression is |
| 310 | itself a macro-form. Returns the resulting expression. |
| 311 | |
304 | 312 | === Macro helper procedures |
305 | 313 | |
306 | 314 | ==== begin-for-syntax |