Annoyance: 'Shadowing declaration is deprecated'+ mixins
Jari-Matti Mäkelä
jmjmak at utu.fi.invalid
Wed Jul 25 02:14:14 PDT 2007
Don Clugston wrote:
> Is there any chance of getting the 'shadowing declaration is deprecated'
> error message disabled, for code inserted via a mixin?
>
> It means that if you inject a 'for' loop into the current function, it
> appears to work, but will fail if another variable with the same name
> already exists.
>
> void main()
> {
> // double i=300.0;
> mixin("for (int i=0; i<10; ++i) { func(i); }");
> }
>
> When such code is generated by a mixin, the shadowing does not indicate a
> probable error.
>
> This is proving to be quite annoying for my BLADE rewrite.
I hope that when macros come there will be a possibility to choose between
hygienic and unhygienic versions. I've started to think string mixins are a
big design mistake. Looking at those compile time unique id hacks from Lisp
coder's POV it's amazing to see how badly you can implement something so
obvious. I wrote about macros a while ago and noticed that by increasing
the power of template mixins and alias parameters it would be possible to
achieve the same things and more without sacrificing e.g. syntactical
transparency.
More information about the Digitalmars-d
mailing list