mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2024-12-23 09:41:36 +00:00
Improve macro definition.
It's more robust to use `let' to have the macro result in its own new scope. (Unrelated to the hygiene point, of course.)
This commit is contained in:
parent
e8f8e2331b
commit
d8989c2ae3
@ -423,8 +423,7 @@ vec ; => #(1 2 3 4)
|
||||
|
||||
;; Macros are hygienic, you cannot clobber existing variables!
|
||||
(define-syntax-rule (swap x y)
|
||||
(begin
|
||||
(define tmp x)
|
||||
(let ([tmp x])
|
||||
(set! x y)
|
||||
(set! y tmp)))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user