Skip to content

Instantly share code, notes, and snippets.

@dpk
Created March 4, 2012 23:57
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dpk/1975487 to your computer and use it in GitHub Desktop.
Save dpk/1975487 to your computer and use it in GitHub Desktop.
define-macro for Chicken Scheme
; 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))))))))))
@Watcom
Copy link

Watcom commented Mar 19, 2012

works quite well, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment