Access syntax object of defined procedure?

Dear all,

I am looking into Racket with an interest in meta-programming/program transformations. Racket's macros & support for pattern-matching the AST are very powerful but appear somewhat static to me. They can be used to encode a one-time transformation of a given piece of code.

I am wondering: is there any way to continue inspecting or transforming procedures once they have already been defined? For example, in Racket BC, it was possible to disassemble bytecode to peek into the underlying representation/S-expressions, but in Racket CS this has been replaced by machine code.

Basically I am looking for a hypothetical (get-syntax-object-of-procedure f) where f is a defined procedure following macro expansion.

Many thanks!


Not by default. But you can create a macro define/stx that defines a structure that pretends to be a procedure. The structure would then hold both the actual procedure and the syntax object.

See also:


That's a great trick, many thanks!