William J. Bowman
unread,Jul 17, 2019, 4:35:21 PM7/17/19Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Racket Users
I'm trying to write a macro that reflects on which identifiers are in scope in
the environment when it runs, and on the identifiers in scope for its generated
code.
It should act something like this:
(define-syntax (display-env stx)
(syntax-case stx ()
[(_)
(printf "Env: ~a" (local-environment))]))
> (lambda (x) (display-env) x)
Env: '(x)
#<procedure>
> (lambda (x) (let-syntax ([y (make-rename-transformer #'x)]) (display-env) y))
Env: '(y x)
#<procedure>
Presumably, the expander knows which identifiers are in scope, so I *ought* to
be able to get my hands on that set.
namespaces aren't the thing; they only give me access to the top-level
definitions, as far as I can tell.
I also want access to any lexical identifiers introduced by `λ` or `let` or
`let-syntaxes` or `let-values` etc.
But I want to be able to use them pretty much like namespaces: get the list of
symbols in scope, and get their values and identifiers.
Any one know how to do this?
--
William J. Bowman