On Wednesday, 27 May 2015 at 11:53:00 UTC, Jacob Carlborg wrote:
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.
Well, that's the point: the function is a normal function, only
some of its parameters require specially prepared arguments, this
can't be missed as soon as arguments are passed to the respective
parameters.
In that case I would prefer the "macro" keyword. It's already a
reserved, for exactly this purpose, so it will be backwards
compatible.
Well, maybe, I just didn't need the keyword.
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.
No, passing of Context is not proposed.
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.
I mean, the template instantiation syntax can inform the compiler
that the expression is evaluated at compile time with possible
code generation, so that the compiler is prepared to what macro
will do. This resembles similarity between macros and templates.
If macros can use existing syntax of a function call, I see no
problem if they use another existing syntax.