Annoyance: 'Shadowing declaration is deprecated'+ mixins

Don Clugston dac at nospam.com.au
Wed Jul 25 03:16:44 PDT 2007


Jari-Matti Mäkelä wrote:
> 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.

My post was actually to indicate that this lack of hygiene is a genuine nuisance
(not merely aesthetically undesirable). I wonder when an unhygienic macro would 
actually be useful.




More information about the Digitalmars-d mailing list