DIP 50 - AST macros

Timon Gehr timon.gehr at gmx.ch
Mon Nov 11 13:23:06 PST 2013


On 11/11/2013 05:47 PM, Dicebot wrote:
> On Monday, 11 November 2013 at 16:28:17 UTC, Timon Gehr wrote:
>> I don't agree. (The argument against implicit mixin features was a
>> complete lack of hygiene, not the mere possibility of accessing the
>> caller scope.)
>
> How would you expect it to be hygienic in any way if it has implicit
> outer scope access? Reasoning is pretty much the same as with mixins.

With mixins _every_ identifier is by _default_ inserted/looked up in the 
so-called 'outer scope', whereas declarations and normal symbol lookups 
within macros are hygienic by default. Macros are as much about 
reflection as about code generation. The trade-offs are simly not the 
same. Implicit outer scope access does not imply it behaves in a 
counter-intuitive manner. (It could just reflect some debug information 
after all, or perform some additional checks on the context for more 
safety, etc.) I will be really unhappy with any proposal that does not 
allow to interchange function calls with macro calls transparently, even 
though such a scheme allows more abusive code to be written as well. If 
in some code base macros should be clearly marked, a naming convention 
(eg. prefix macro names with 'macro') can be used. (Enforcing such a 
convention is trivial and amounts to eg. a few lines of additional code 
in a modified D front end.)



More information about the Digitalmars-d mailing list