On Thu, 08 Jul 2010 20:43:39 -0400, Jonathan M Davis
<[email protected]> wrote:
Periodically, the term AST macros come up in the discussions here as a
possible
addition to the language - they even get discussed briefly in TDPL as a
possible
replacement for template mxins. However, I don't think that I've ever
seen an
actual explanation for what exactly is meant by the term AST macro. This
raises
two questions
1. What are AST macros and how do they differ from C-style macros? We
obviously
aren't going to be adding macros like that to D, since that would be
dangerous.
But what would a macro be then if it's not a textual replacement? The
best I can
think of would be that you'd have to indicate the macros to be replaced
by
surrounding them with macro() or something rather than letting any and
all text
that matches be replaced. So, I really don't know what AST macros are
supposed
to be other than they're macros of some kind and better than C-style
macros.
2. What does AST stand for? The best that I can come up with for what it
could
stand for would be Abstract Syntax Tree, which is a nice, Computer
Sciency,
compiler-related term, but I haven't a clue how that would relate to
macros. So,
maybe an answer to the first question would answer this one as well, but
an
explanation would be nice.
- Jonathan M Davis
Check out Walter's slides and/or talk from the D conference.
(http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=12555)
AST does stand for abstract syntax tree and they are much more like Lisp
macros as opposed to the C preprocessor.