Created
March 4, 2012 23:57
-
-
Save dpk/1975487 to your computer and use it in GitHub Desktop.
define-macro for Chicken Scheme
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
; kind of a stupid implementation but with | |
(define-syntax define-macro | |
(er-macro-transformer | |
(lambda (exp rename compare) | |
(if (symbol? (cadr exp)) | |
(let ((name (cadr exp)) | |
(expndr (caddr exp)) | |
(-exp (gensym)) (-rename (gensym)) (-compare (gensym))) | |
`(define-syntax ,name | |
(er-macro-transformer (lambda (,-exp ,-rename ,-compare) | |
(apply ,expndr (cdr ,-exp)))))) | |
(let ((name (caadr exp)) | |
(formals (cdadr exp)) | |
(body (cddr exp)) | |
(-exp (gensym)) (-rename (gensym)) (-compare (gensym))) | |
`(define-syntax ,name | |
(er-macro-transformer (lambda (,-exp ,-rename ,-compare) | |
(apply (lambda ,formals ,@body) (cdr ,-exp)))))))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
works quite well, thanks!