What are AST Macros?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Tue Jul 13 09:08:01 PDT 2010


On 07/13/2010 10:43 AM, retard wrote:
> Yes, this would be possible if the dmd compiler didn't crash, leak memory
> etc. The quality is so shitty that I'd say that implementing a compile
> time AST parser for D 2 is almost impossible.

Well it should be said that the quality of the compiler has dramatically 
improved over the past months. I think it would be worth writing a 
tokenizer for starters.

> And what's worse is that
> the language is changing constantly so the AST parser meta-library would
> need to be updated once in a while. This is great news for all the fans
> of NIH syndrome.

The rate of language changes has slowed down very visibly since TDPL has 
come out.

>> String manipulation scales very poorly, it's error prone, and it's
>> tedious.
>
> Like Andrei said, real AST macros can also be hairy, but they _are_ an
> improvement over string based macros in many cases. Lisp users have 50+
> years of experience with meta-programming. You're mostly talking with
> amateurs here. Of course they don't see the value of true macros. One
> fundamental prerequisite when discussing macros is that you've actually
> used them in at least ONE other language.

Agreed. Reminds me of the Go programmers who don't need generics :o). 
The Sapir-Whorf theory may or may not apply to natural language, but has 
a visible presence in programming languages.


Andrei


More information about the Digitalmars-d mailing list