3 ms·
But you can do this without S-expressions. DLang, for example, has free-form macros that they weirdly call "mixin" (as in, mixing in some text or declarations
by Peaker 9y ago
But you can do this without S-expressions.
DLang, for example, has free-form macros that they weirdly call "mixin" (as in, mixing in some text or declarations into the AST, syntax-wise).
Each mixin must be a valid AST subtree on its own, which gives the same guarantee that paren matching prior to macro expansion gives you.
Then, the compiler can interleave:
parsing
-> evaluating mixin strings
-> resuming parsing of the mixin subtrees
-> evaluating the deeper mixin strings
-> ...
You get the power of Lisp macros, but without the Lisp syntax that is unattractive to many.