Annoyance: 'Shadowing declaration is deprecated'+ mixins

Stewart Gordon smjg_1998 at yahoo.com
Wed Jul 25 10:27:07 PDT 2007


"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?

Stewart. 




More information about the Digitalmars-d mailing list