This commit is contained in:
Justin Ethier 2021-08-23 13:36:13 -04:00
parent 630f36dc03
commit fc92f9c302

View file

@ -168,7 +168,7 @@ A [R<sup>7</sup>RS Compliance Chart](Scheme-Language-Compliance.md) lists differ
Cyclone provides two macro systems. Cyclone provides two macro systems.
High-level hygienic macros may be created using `syntax-rules`. This system is based on a template language specified by R<sup>7</sup>RS. The specification goes into more detail on how to work with these macros. High-level hygienic macros may be created using `syntax-rules`. This system is based on a template language specified by R<sup>7</sup>RS. The specification goes into more detail on how to work with these macros:
(define-syntax when (define-syntax when
(syntax-rules () (syntax-rules ()
@ -176,7 +176,7 @@ High-level hygienic macros may be created using `syntax-rules`. This system is b
(if test (if test
(begin result1 result2 ...))))) (begin result1 result2 ...)))))
Alternatively a low-level explicit renaming (ER) macros system is also provided that allows defining macros using Scheme code, in a similar manner as `defmacro`. This macro system provides the convenience functions `(rename identifier)` to hygienically rename an identifier and `(compare identifier1 identifier2)` to compare two identifiers. Alternatively a low-level explicit renaming (ER) macros system is also provided that allows defining macros using Scheme code, in a similar manner as `defmacro`. This macro system provides the convenience functions `(rename identifier)` to hygienically rename an identifier and `(compare identifier1 identifier2)` to compare two identifiers:
(define-syntax when (define-syntax when
(er-macro-transformer (er-macro-transformer
@ -194,7 +194,7 @@ Alternatively a low-level explicit renaming (ER) macros system is also provided
cyclone> (expand '(when #t (+ 1 2 3)) *global-environment* '()) cyclone> (expand '(when #t (+ 1 2 3)) *global-environment* '())
(if #t ((lambda () (+ 1 2 3))) ) (if #t ((lambda () (+ 1 2 3))) )
- Alternatively when developing an ER macro, since its just a Scheme function, the macro can be defined as a `lambda` and passed a quoted expression to debug. - Alternatively when developing an ER macro, since its just a Scheme function, the macro can be defined as a `lambda` and passed a quoted expression to debug:
(pretty-print (pretty-print
((lambda (exp rename compare) ((lambda (exp rename compare)