Am 26.06.2014 02:41, schrieb Walter Bright:
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.
what about adding tests -no-global-shadowing (or others) to dmd and tell
people to use it - poeple will definitly change there global names then
(like your advised of renameing or using .x etc) and after a while it
could become a warning, then an error - like the time between
deprecation and removal of an feature - D need more strategies then C++
to add better qualitity over time