More name hiding

Timon Gehr timon.gehr at gmx.ch
Sat Aug 20 11:37:46 PDT 2011


On 08/20/2011 08:21 PM, bearophile wrote:
> Timon Gehr:
>
>> In some cases, shadowing can be handy for code generation via string
>> mixins (the shadowing that is disallowed, not the shadowing of globals).
>
> Making the language more forbidding makes the generation of code simpler. But it's simpler to write code that generates correct code, than for humans to write bug-free code. So it's much more important to design the language to be good (not bug-prone) to be written by hand.
>
> Bye,
> bearophile

Actually, since some forms of shadowing are still allowed, it makes the 
generation of code slightly more complex. If your other statement holds 
true, we can as well allow shadowing and require all code to be wrapped 
inside a string mixin instead :o). I consider code generation via string 
mixins something the language is worth optimizing for, because it is so 
useful. Fighting with the compiler about shadowed variables in the 
generated code is not pleasant, because you have to resort to ugly 
workarounds to make it shut up. (those then may introduce bugs in your 
code generating code).


More information about the Digitalmars-d mailing list