4 ms·
Could you explain what phase is? I understand haskell types, and I suspect Template haskell mostly works as an AST translator. A Google search on macros and pha
by julian_1 9y ago
Could you explain what phase is? I understand haskell types, and I suspect Template haskell mostly works as an AST translator. A Google search on macros and phase, just turns up diet and bodybuilding preparation advice!
- dbpatterson 9y agoIn the simplest case, a macro system gives rise to two-phase evaluation - first, there is code that runs at macro expansion time, that produces, as its result, new syntax, and second, that resulting code runs. But having just two phases is (needlessly) restrictive, because you might want macros that generate other macros (and so the macro-generating macros would need to run at an earlier phase than the generated ones).
- chongli 9y agoWouldn't the macro-expansion phase be run until it reaches a fixed point? That way all macros could be fully expanded before proceeding to the next phase.
- wtetzner 9y agoI believe that's how macros in Racket work, but each iteration is considered a separate phase. At least, that's how I understood it. This page has some useful information about phases: https://docs.racket-lang.org/guide/phases.html https://docs.racket-lang.org/guide/phases.html