Skip to main content

projection3_source

Function projection3_source 

Source
pub fn projection3_source() -> Result<String, String>
Expand description

Third Futamura Projection: PE(PE, PE) = compiler_generator

Specializes the partial evaluator with respect to itself, producing a compiler generator (cogen). Feed it any interpreter → it produces a compiler for that interpreter’s language.

Chain: cogen(int) → compiler → compiler(P) → compiled

For the CExpr/CStmt representation, PE(PE, PE) yields the PE with entry points renamed to cogenExpr/cogenBlock. This works because the PE’s self-application is idempotent: the PE already operates on the same representation it would specialize, so PE(PE, PE) = PE (up to naming). The cogen handles different interpreters (Core, RPN, etc.) by processing their encoded CProgram representations.