Created
November 12, 2012 14:28
-
-
Save greghendershott/4059716 to your computer and use it in GitHub Desktop.
with-syntax* ?
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 | |
;; This has a nested with-syntax | |
(define-syntax (good stx) | |
(syntax-case stx () | |
[(_ x ...) | |
(with-syntax ([(y ...) #'(x ...)]) | |
(with-syntax ([(z ...) (generate-temporaries #'(y ...))]) | |
#'(let ([z x] ...) | |
#t)))])) | |
;; I thought I could avoid that using with-syntax | |
(define-syntax (not-ok stx) | |
(syntax-case stx () | |
[(_ x ...) | |
(with-syntax* ([(y ...) #'(x ...)] | |
[(z ...) (generate-temporaries #'(y ...))]) | |
#'(let ([z x] ...) | |
#t))])) | |
;; But it complains: | |
;; ...: ellipses not allowed as an expression in: ... | |
;; highlighting the ... in (y ...) | |
;; Is this a bug, or an undocumented as-intended limitation of with-syntax*? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The way I debugged this: I used the macro stepper, disabled macro hiding, and watched as the expander thought that 'with-syntax_' was a plain old function that it didn't know about yet: it introduced #%app's, and then started walking through the "operands", and finally raised an error when it hit the ellipsis. As soon as I saw it was treating with-syntax_ as plain old function, that caught my attention.