3 ms·
You are aware that Racket (hygienic) macros are Turing-complete? You can loop and branch, and macro expansion may not terminate too. I think only OCaml functor
by klibertp 14y ago
You are aware that Racket (hygienic) macros are Turing-complete? You can loop and branch, and macro expansion may not terminate too.
I think only OCaml functors really qualify to what you call "principled", but then - it's not the most powerful kind of metaprogramming I've seen.
- colanderman 14y agoMm, last time I used Racket (then PLT Scheme) macros I did not encounter those features… the only "looping" I saw was limited to the "..." construct (which is a finite expansion), and all branching was lexical (i.e. branching couldn't be used to form infinite loops). If I am incorrect then I retract my Racket example.
- klibertp 14y agoYou're most likely incorrect - I cannot be sure about Racket back when it wasn't called that, but Scheme hygienic macro systems - those created with SYNTAX-RULES - are Turing complete. Look here for a "primer" which explains how to 'loop' (by means of recursion) and branch with pattern matching. At the end of a tutorial you can find basic Scheme interpreter written as a set of Scheme macros. For example, in terms of this macro system, you can (and you could for a long time) define a simplest non-terminating macro like this: (define-syntax loop (syntax-rules () ((loop) (loop)))) Racket Macro Stepper gives a following warning when used to step through the macro expansion: Macro expansion has taken a suspiciously large number of steps. Click Stop to stop macro expansion and see the steps taken so far, or click Continue to let it run a bit longer.