mirror of
https://github.com/adambard/learnxinyminutes-docs.git
synced 2025-01-14 05:05:59 +00:00
Quick bad-macro example.
This commit is contained in:
parent
0063574a4d
commit
d97565efa1
@ -353,7 +353,7 @@ m ; => '#hash((b . 2) (a . 1) (c . 3)) <-- no `d'
|
||||
(for ([i (in-range 5 10)])
|
||||
(printf "i=~a\n" i)) ; => i=5, i=6, ...
|
||||
|
||||
;;; Other Sequences
|
||||
;;; Iteration Over Other Sequences
|
||||
;; `for' allows iteration over many other kinds of sequences:
|
||||
;; lists, vectors, strings, sets, hash tables, etc...
|
||||
|
||||
@ -557,6 +557,14 @@ vec ; => #(1 2 3 4)
|
||||
(swap! a b)
|
||||
(printf "tmp = ~a; a = ~a; b = ~a\n" tmp a b) ; tmp is unaffected
|
||||
|
||||
;; But the are still code transformations, for example:
|
||||
(define-syntax-rule (bad-while condition body ...)
|
||||
(when condition
|
||||
body ...
|
||||
(bad-while condition body ...)))
|
||||
;; this macro is broken: it generates infinite code, if you try to use
|
||||
;; it, the compiler will get in an infinite loop
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; 10. Contracts
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
Loading…
Reference in New Issue
Block a user