DIP 50 - AST macros

deadalnix deadalnix at gmail.com
Wed Nov 13 17:56:20 PST 2013


On Thursday, 14 November 2013 at 01:38:29 UTC, Walter Bright 
wrote:
> On 11/13/2013 5:14 PM, deadalnix wrote:
>> My very first project in D involved quite a lot of them. So I 
>> very aware of what
>> they are.
>>
>> The whole idea is to be able to extends that to statement and 
>> declarations.
>
> My question about that is just what problem is this trying to 
> solve, and why that problem cannot be reformulated in terms of 
> expression templates?
>
> I.e. we shouldn't be adding things to D just because they are 
> cool. They need to solve a problem that is fairly commonplace 
> and too painful to solve with existing mechanisms. The larger 
> the proposed language enhancement is, the more commonplace and 
> and painful the problems must be that it purports to solve.
>

I think the whole point of macro is to NOT add too much feature 
to the language.

See for instance the example I gave before to create generator. 
This can be added with extra language support (C# async/await is 
an example). But with macro, the feature can be implemented as a 
library.

It is NOT achievable with expression templates.

I can say with certainty that the async/await mechanism is 
heavily used in some codebases and with great benefit. It is 
being added to all languages one after another.

The idea behind macros is that instead of adding new feature to 
the language, the language should propose a toolkit to build 
these features as library.

I don't think the time has come for macros in D. As discussed 
before, it seems like filling the gap in existing feature is more 
important than adding new ones. This should however be considered 
very seriously when the gaps has been filled.


More information about the Digitalmars-d mailing list