2016-07-16 05:56:50 +00:00
|
|
|
|
2016-07-16 15:18:11 +00:00
|
|
|
;; (display "define-syntax...")
|
2016-07-16 05:56:50 +00:00
|
|
|
|
2016-07-16 15:18:11 +00:00
|
|
|
;; (define-macro define-syntax
|
|
|
|
;; (lambda (form expander)
|
|
|
|
;; (expander `(define-macro ,(cadr form)
|
|
|
|
;; (let ((transformer ,(caddr form)))
|
|
|
|
;; (lambda (form expander)
|
|
|
|
;; (expander (transformer form
|
|
|
|
;; (lambda (x) x)
|
|
|
|
;; eq?)
|
|
|
|
;; expander))))
|
|
|
|
;; expander)))
|
2016-07-16 05:56:50 +00:00
|
|
|
|
2016-07-16 15:18:11 +00:00
|
|
|
;; (newline)
|
2016-07-16 05:56:50 +00:00
|
|
|
|
|
|
|
(display "define-syntax when...")
|
|
|
|
|
|
|
|
;; (define-syntax when
|
|
|
|
;; (syntax-rules ()
|
|
|
|
;; ((when condition exp ...)
|
|
|
|
;; (if condition
|
|
|
|
;; (begin exp ...)))))
|
|
|
|
|
|
|
|
;; (define-macro (when cond exp . rest)
|
|
|
|
;; `(if ,cond
|
|
|
|
;; (begin ,exp . ,rest)))
|
|
|
|
|
|
|
|
|
2016-07-16 15:18:11 +00:00
|
|
|
;; (define-macro (when clause . rest)
|
|
|
|
;; (list 'cond (list clause (list 'let '() rest))))
|
2016-07-16 05:56:50 +00:00
|
|
|
|
|
|
|
|
2016-07-16 15:18:11 +00:00
|
|
|
(define-macro (when expr . body)
|
|
|
|
`(if ,expr
|
|
|
|
((lambda () ,@body))
|
|
|
|
'bah))
|
2016-07-16 05:56:50 +00:00
|
|
|
|
|
|
|
(newline)
|
|
|
|
|
2016-07-16 15:18:11 +00:00
|
|
|
(when #t
|
2016-07-16 05:56:50 +00:00
|
|
|
(display "true")
|
|
|
|
(newline))
|
|
|
|
|
2016-07-16 15:18:11 +00:00
|
|
|
(when #t
|
|
|
|
(display "q-when")
|
2016-07-16 05:56:50 +00:00
|
|
|
(newline)
|
|
|
|
'())
|
|
|
|
|
|
|
|
(define *gensym* 0)
|
|
|
|
(define (gensym)
|
|
|
|
(set! *gensym* (+ *gensym* 1))
|
|
|
|
(string->symbol (string-append "g" (number->string *gensym*))))
|
|
|
|
|
|
|
|
(newline)
|