What are AST Macros?

Rainer Deyke rainerd at eldwood.com
Mon Jul 12 22:02:25 PDT 2010


On 7/12/2010 19:41, Nick Sabalausky wrote:
> I already agreed to that part ("For writing, yes..."). But there are other 
> uses that *do* parse, and others that do both. The point is NOT that string 
> mixins are *always* unsatisfactory as a replacement for AST macros. The 
> point is that *there are perfectly legitimate use-cases* where string mixins 
> are unsatisfactory as a replacement for AST macros. I think you've already 
> agreed to this in other posts.

The great strength of string mixins is that you can use them to add the
AST macros to D.  The great weakness of string mixins is that doing so
requires a full (and extendable) CTFE D parser, and that no such parser
is provided by Phobos.

It would be interesting to try the "extendable CTFE D parser" route
instead of the "AST macros as built-in primitive" route.  For example,
you could use it to add new lexical tokens to D, something that would be
impossible with AST macros.


-- 
Rainer Deyke - rainerd at eldwood.com


More information about the Digitalmars-d mailing list