Is it possible to compile macros to machine code? I mean compiling the macro itself rather than compiling the the code generated by the use of the macros.
This might be useful to speed compilation of programs in domain-specific languages that are defined mainly by macros. Rather than having to interpret the code of the macros itself every time each one used, one could have something closer to machine code effecting the expansion.
Racket macro implementations are compiled to machine code.
For macros that are defined used within the same module, and where a tiny interpreter for trivial compile-time expressions does not apply, the macro implementation is compiled with a lower level of optimization than usual. This heuristic trades some macro run time to reduce macro compile time.
For macros that are defined in one module and used in another, however, the macro implementation is compiled again (for use in other modules) at a normal optimization level.