Will macros work with expressions?

Don Clugston dac at nospam.com.au
Thu Sep 6 00:27:43 PDT 2007


Reiner Pope wrote:
> Jari-Matti Mäkelä wrote:
>> Robert Fraser wrote:
>>> Jari-Matti Mäkelä Wrote:
>>
>>>> If I understood it correctly, the macros only do a simple substitution
>>>> using their parameters, hide symbols when necessary (hygiene) and then
>>>> attach the generated code to the AST.
>>> I think that's about right, but remember that their parameters can
>>> specialize on any pattern and extract parts of the expression, which I
>>> think is the most exciting feature.
>>
>> Ah, good point. That would make overloading and recursive calls the 
>> primary
>> control flow constructs then. 
> 
> Such an environment is not pleasant as it involves large code overheads. 
> It's what's required in C++ template metaprogramming; D made this *much* 
> nicer by introducing static if. 

And even better (perfect in many cases) with CTFE.

> Please don't take a step backwards with macros.

This was the reaction I had too. There's really no need for macros to provide 
new functionality, they just need to provide syntax sugar for what we can 
already do with string mixins.



More information about the Digitalmars-d mailing list