Will macros work with expressions?

Don Clugston dac at nospam.com.au
Fri Sep 7 07:28:42 PDT 2007


Reiner Pope wrote:
> Don Clugston wrote:
>> 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.
> 
> But the hygiene of macros is certainly appealing, no?

Definitely. But I was hoping that the inability to have hygienic string mixins 
was a temporary aberration.



More information about the Digitalmars-d mailing list