Last active
August 29, 2015 14:26
-
-
Save takikawa/cfb68e845e18fc17444e 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 | |
(require (for-syntax syntax/stx)) | |
(define-syntax (m1 stx) | |
(syntax-case stx () | |
[(_ i1) | |
(let () | |
(define i2 (car (generate-temporaries '(1)))) | |
#`(begin (quote-syntax #,i2) | |
(define-syntax i1 (make-rename-transformer (quote-syntax #,i2))) | |
(define #,i2 'dummy) | |
0))])) | |
(define-syntax (m2 stx) | |
(define expanded (local-expand (stx-car (stx-cdr stx)) 'expression null)) | |
(displayln (syntax->datum expanded)) | |
(syntax-case expanded (let-values begin quote-syntax) | |
;; match expansion on HEAD | |
[(let-values () (let-values ((() (begin (quote-syntax x) _))) (let-values (((y) _)) _))) | |
(displayln (free-identifier=? #'x #'y)) | |
#'(void)] | |
;; match expansion on 6.2 | |
[(let-values () (e ... ((() (begin (quote-syntax x) _)) ((y) _)) body)) | |
(displayln (free-identifier=? #'x #'y)) | |
#'(void)])) | |
(m2 | |
(let () | |
(m1 x))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment