On 6/25/2014 4:03 PM, bearophile wrote:
The simplest way to avoid that kind of bugs is give a "shadowing global x error"
(similar to the shadowing errors D gives with foreach and with statements). But
this breaks most existing D code.

D has scoped lookup. Taking your proposal as principle, where do we stop at issuing errors when there is the same identifier in multiple in-scope scopes? I think we hit the sweet spot at restricting shadowing detection to local scopes.

I suggest that your issues with global variables can be mitigated by adopting a distinct naming convention for your globals. Frankly, I think a global variable named "x" is execrable style - such short names should be reserved for locals.

Reply via email to