Shadowing of members

bearophile bearophileHUGS at lycos.com
Wed Jan 9 19:13:00 PST 2013


Walter Bright:

> Denied. I don't see the rationale for in one case but not 
> others.

There is a rationale. In my opinion special cases are bad in a 
language, unless:
- They always produce a compilation failure in a well defined 
group of cases. (while just giving a different answer in a 
vaguely defined group of cases is usually not acceptable);
- They help the programmer avoid a common bug-prone situation.

In D we have already some cases of such special rules, that break 
uniformity and symmetry to help D programmers write less buggy 
code.

Issue 4407 (
http://d.puremagic.com/issues/show_bug.cgi?id=4407 ) is/was one 
of my fifteen most important enhancement requests (and it's a 
small one). Many of those fifteen are little breaking changes.

I think the case discussed in Issue 4407 passes both conditions:

The cause is defined for class/structs. I think this is a 
definite enough situation

Regarding commonality:
- I know two tools that detect this bug, the tool that has 
already found some (different) bugs in the DMD source code and 
the Google Web Toolkit.
- I have created several bugs because of that, and I am forced to 
use a coding convention (like adding a trailing _ to argument 
names in constructors) to avoid them.
- I know three D programmers that have had the same problem of 
mine, Byron Heads, the OP and another person.
- The static analysis tool I was referring before has uncovered 
cases of such bug in well used C++ code.

Bye,
bearophile


More information about the Digitalmars-d mailing list