[plt-scheme] Check Syntax & mangled identifiers

From: Tom Schouten (tom at zwizwa.be)
Date: Sat May 23 01:44:26 EDT 2009


In the following, is there a way to instruct Check Syntax to recognize
the #'x identifier in reference and binding position as in case 1, or
in its relation to the #'_x identifier as in case 2 ?

#lang scheme
(require (for-syntax scheme))

(define-for-syntax (underscore stx)
  (datum->syntax stx
                  (format "_~a"
                          (syntax->datum stx)))))

(define-syntax (u stx)
  (syntax-case stx ()
    ((_ (name val) . body) #`(let ((#,(underscore #'name) val)) . body))
    ((_ id) (underscore #'id))))

;; case 1
(u (x 123) (u x))       

;; case 2
(let ((_x 123)) (u x))
(u (x 123) _x)


Posted on the users mailing list.