Annoyance: 'Shadowing declaration is deprecated'+ mixins

Jari-Matti Mäkelä jmjmak at utu.fi.invalid
Wed Jul 25 11:17:22 PDT 2007


Stewart Gordon wrote:

> "Pragma" <ericanderton at yahoo.removeme.com> wrote in message
> news:f85gh5$g8l$1 at digitalmars.com...
> <snip>
>> It kinda makes me wish D had a __UNIQUE__ symbol (reliably unique for a
>> given module/compilation unit?)  for this kind of stuff.
>>
>> const char[] sym = __UNIQUE__;
>> mixin("for (int " ~ sym ~ "=0; " ~ sym ~ "<10; ++" ~ sym ~ ") { func(" ~
>> sym ~ "); }");
> 
> Why create a workaround for this language deficiency rather than fixing
> it?
> 
> http://www.digitalmars.com/d/pretod.html#mixins
> "Mixins create a scope, macros do not."
> "Mixins automatically create unique identifiers as required using a
> standard algorithm, macros have to do it manually with kludgy token
> pasting."
> 
> This of course applies to template mixins.  But why not make these points
> apply to text mixins just the same?

Or extend templates to contain statements so you get three flies with one
hit: macros, a fix to this problem & syntax highlighting back. Well, not
completely, but the other deficiencies should be obvious by then.



More information about the Digitalmars-d mailing list