[plt-scheme] syntax-case + quote as a pattern variable
Hi,
I recently faced the situation where I wanted to both have a quote in the pattern and to create a non-hygienic identifier using datum->syntax in a syntax-case, I got the following error : the pattern variable "quote" cannot be use in this context.
A minimal example :
(define-syntax test (λ (stx) (syntax-case stx () [(t 'x) (with-syntax ([id (datum->syntax (syntax t) 'id) ]) #' (define id x))])))
>(define x 4)>(test 'x)>id
My solution was to bind the symbol in a let before the syntax-case :
(define-syntax test (let ([s 'id]) (λ (stx) (syntax-case stx () [(t 'x) (with-syntax ([id (datum->syntax (syntax t) s) ]) #' (define id x))]))))
I'm curious to hear what syntax-case experts have to say about it.
Thanks.
_________________________________________________________________
Obtenez Windows 7 pour aussi peu que 39,99 $ – étudiants d’établissements collégiaux et universitaires canadiens seulement. L’offre prend fin le 3 janvier : achetez-le maintenant!
http://go.microsoft.com/?linkid=9691829