3 ms·
It doesn't strictly have a 1-1 relationship because of macros themselves. They're Turing complete, so the same macro can expand into different ASTs based on use
by phoe-krk 9y ago
It doesn't strictly have a 1-1 relationship because of macros themselves. They're Turing complete, so the same macro can expand into different ASTs based on user input during compilation, presence of any files on the hard drive or even moon phases, so I have to say that this relationship is much more complicated than a simple 1-1. For very simple functions like (lambda (x) (* x x)) this is true, but macros' power greatly complicates it.
- dangerbird2 9y agoI should have said a read and macroexpanded lisp source has a 1-1 relationship with the AST. As an aside, the bigger distinction between something like C++ template metaprogramming and Lisp metaprogramming is that while C++ uses a template language completely orthogonal to the runtime language, Lisp macros is nothing more than Lisp code executed at macroexpand-time rather than eval-time.
- kazinator 9y agoA Lisp form with unexpanded macros has abstract syntax; the unexpanded macro forms are AST material.