Created
March 28, 2014 14:32
-
-
Save samth/9834239 to your computer and use it in GitHub Desktop.
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
#lang racket | |
(module m1 racket | |
(require (for-syntax racket/pretty)) | |
(define-syntax (modbeg stx) | |
(syntax-case stx () | |
[(_ forms ...) | |
(let () | |
(define expanded (local-expand #'(#%plain-module-begin forms ...) 'module-begin null)) | |
(pretty-print (syntax->datum expanded)) | |
(syntax-case expanded () | |
[(_ ... (quote last)) | |
(identifier? #'last) | |
(begin (eprintf "~a\n" (syntax-local-value #'last)) | |
#'(#%plain-module-begin (void)))] | |
[_ #'(#%plain-module-begin (void))]))])) | |
(provide (rename-out [modbeg #%module-begin]) | |
(except-out (all-from-out racket) #%module-begin))) | |
(module m2 (submod ".." m1) | |
(define-syntax x (lambda (stx) #''x)) | |
x) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment