This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; syntax | |
(define-syntax my-when | |
(syntax-rules () | |
((_ pred b1 ...) | |
(if pred (begin b1 ...))))) | |
(my-when (> 0 -1) | |
(display "hello") | |
(newline)) | |
;; hello | |
;; #<undef> | |
(macroexpand | |
'(my-when (> 0 -1) | |
(display "hello") | |
(newline))) | |
; -> (#<identifier user#if> (> 0 -1) (#<identifier user#begin> (display "hello") (newline))) | |
;; (#<identifier user#if> (> 0 -1) | |
;; (#<identifier user#begin> | |
;; (display "hello") | |
;; (newline))) | |
(define-syntax my-unless | |
(syntax-rules () | |
((_ pred b1 ...) | |
(if (not pred) (begin b1 ...))))) | |
(my-unless (> 0 1) | |
(display "world") | |
(newline)) | |
;; world | |
;; #<undef> | |
(macroexpand '(my-unless (> 0 1) | |
(display "world") | |
(newline))) | |
; -> (#<identifier user#if> (#<identifier user#not> (> 0 1)) (#<identifier user#begin> (display "world") (newline))) | |
;; (#<identifier user#if> (#<identifier user#not> (> 0 1)) | |
;; (#<identifier user#begin> | |
;; (display "world") | |
;; (newline))) |
0 件のコメント:
コメントを投稿