[plt-scheme] preserving the lack of an inferred name

From: Doug Orleans (dougo at place.org)
Date: Fri Jun 18 20:45:28 EDT 2004

Eli Barzilay writes:
 >   (define-syntax (keep-name stx)
 >     (syntax-case stx ()
 >       ((_ x)
 >        (let ((name (syntax-local-name)))
 >          (with-syntax ((x (syntax-property #'x 'inferred-name name))
 >                        (name name))
 >            (syntax/loc stx
 >              (begin (display 'name)
 >                     (newline)
 >                     x)))))))

Well, the point (which may have been lost in my toy example) is that I
need to use `let' in the macro because I need to refer to the
expression twice, but only want to execute it once.  I tried using
`((lambda (foo) ...) x)' but that cleverly sets the inferred name the
same as `(let ((foo x)) ...)'.

--dougo at place.org


Posted on the users mailing list.