Domain-specific languages (DSLs) are typically implemented by code generation, in which domain-specific constructs are translated to a general-purpose “host ” language. Aspect-oriented languages go one step further. An aspect weaver doesn’t just generate code, it transforms code in the host language. In both cases, one of the major challenges in building and using the DSL is achieving good integration between the code generator and the host language. Generated code should be type safe, and any errors should be reported before generation. Partial evaluation and multi-stage languages are excellent tools for implementing ordinary DSLs which satisfy these requirements. Combining partial evaluation with reflection could potentially yield a syste...