dup field in sub-class should be reported by the compiler

Brad Roberts braddr at puremagic.com
Mon Aug 13 16:02:38 PDT 2007


On Mon, 13 Aug 2007, Walter Bright wrote:

> Chris Nicholson-Sauls wrote:
> > Or, as has happened to me a time or two, the programmer may not even /know/
> > what's in the super class, if deriving from a class provided by a library
> > for example.  (This is particularly true with private fields, of course.)
> 
> Exactly what problem does this solve? If you're writing a derived class, and
> you create another field of the same name as a field in the base class, what
> bug has been created? The base class functions will still use the base class
> field, the derived class functions will still use the derived class field. The
> fields aren't polymorphic, so no hijacking can happen.
> 
> I just don't see the issue.

Apply this same logic to variable shadowing.  Shadowing has been declared 
illegal.



More information about the Digitalmars-d mailing list