Rename support for derived names to DrRacket
When a macro creates bindings using derived names, they are not considered to be references to the original name (which is the expected behavior). However, renaming does not work with derived names.
Here's a simple example of a macro:
(define-syntax (my-syntax stx)
(syntax-case stx ()
[(_ name)
(with-syntax ([get-name (format-id #'name "get-~a" #'name)])
#'(begin
(define name 42)
(define (get-name) name)))]))
In the code below, renaming foo
on the first line to bar
with right-click → Rename foo
correctly renames foo on the second line, but does not rename get-foo
on the third line.
(my-syntax foo)
foo
(get-foo)
For example, is there some syntax property that I can bind to foo
and get-foo
to provide a rename helper (which could create a list of original / renamed pairs)?
As a last resort, I could use a fixed convention and use a read extension to actually expand get-foo
to (get foo)
, although I'm not sure if that would even work.
source to share