Skip to content

Instantly share code, notes, and snippets.

@deeglaze
Created October 15, 2012 16:32
Show Gist options
  • Save deeglaze/3893452 to your computer and use it in GitHub Desktop.
Save deeglaze/3893452 to your computer and use it in GitHub Desktop.
A better define-syntax-rule
(require (for-syntax syntax/parse))
; syntax classes, syntax-parse patterns and unquote-syntax in your define-syntax-rule!
(define-syntax (define-syntax-rule* stx)
(syntax-parse stx
[(_ (name patterns ...) body ...)
(syntax/loc stx
(define-syntax (name syn)
(syntax-parse syn
[(_ patterns ...)
(quasisyntax/loc syn (begin body ...))])))]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment