DIP78 - macros without syntax extensions

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Wed May 27 04:53:07 PDT 2015


On 2015-05-27 10:06, Kagamin wrote:

> I believe 78 allows a simpler implementation and requires less changes
> to the language, though I'm not sure if frontend can get it done on a
> purely semantical level: similar techniques like mixins and static if
> rely on syntax.

DIP50 would require a minimal amount of syntax change, the only thing is 
prefixing a function with the "macro" keyword. DIP78 on the other hand, 
it's not so easy to see that a function declaration is actual a macro 
declaration.

In that case I would prefer the "macro" keyword. It's already a 
reserved, for exactly this purpose, so it will be backwards compatible.

I would say that neither of the DIP's contain a lot of detail. So it's 
hard to know which one is more complex. In DIP50 there's quite a lot of 
optional/bonus features. To me, implementing only the minimal 
requirements look very similar to DIP78.

One thing that would be more complex in DIP50 would be the "Context" 
class. Although I'm not sure if that's needed in DIP78 as well.

> Maybe a macro should be called with a special syntax,
> e.g. myAssert!(a==b);

I have thought of that too. But I haven't been able to come up with a 
syntax that looks good and doesn't conflict with any existing 
syntax/symbol. The above syntax is already used for template instantiation.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list