Created
April 13, 2017 16:27
-
-
Save samth/e1770211d010afa547825e600f7f0279 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 | |
;; not working | |
(module not-working racket | |
(define-for-syntax b (box #f)) | |
(define-syntax (pull stx) (unbox b)) | |
(define-syntax (bind stx) | |
(syntax-case stx () | |
[(_ i body) | |
(begin (set-box! b #'i) | |
#'(lambda (i) body))])) | |
(bind x (pull))) | |
;; working | |
(module working racket | |
(define-for-syntax b (box #f)) | |
(define-syntax (pull stx) (unbox b)) | |
(define-syntax (bind stx) | |
(syntax-case stx () | |
[(_ i body) | |
#'(lambda (i) (with-id i body))])) | |
(define-syntax (with-id stx) | |
(syntax-case stx () | |
[(_ i body) (begin (set-box! b #'i) #'body)])) | |
(bind x (pull))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment