digitalmars.D - override deprecated
- Steve Teale (27/27) Jan 27 2014 I'm sure this was discussed at great length sometime, but
- bearophile (8/12) Jan 27 2014 A better compiler design is to have warning activated on default
- Dicebot (5/8) Jan 27 2014 Based on my C++ memories it is quite common issue when working in
- Steve Teale (5/9) Jan 27 2014 That is of course true. The worst case then being that other
I'm sure this was discussed at great length sometime, but yesterday (and the day before) I had one of those days where I turned on warnings , and told the compiler not to ignore deprecated things. Most of the warnings were probably due to keyboard repeats where I had held a key down fractionally too long while typing the semicolon to end whatever. The other common case was fall-through in case statements - in that case, very insidious, and the warnings very helpful All of the deprecated things in in my cleanup were those many cases where I had provided alternative definitions for virtual functions in derived classes without using override. Now I can vaguely see the reasoning for insistence on the override keyword. It's kind of a consequence of Walter's decision that all member functions are virtual unless ... But as I plodded through my code base, I came across not a single situation where the declaration of a virtual function in some derived class was an error. I found a few where the declarations were redundant, in that they were the same in effect as the function defined in the parent class, but I was left feeling cheated. Being picky about the code had not given me any tangible benefit. Would it be reasonable to ask for the compiler to generate a warning if it found that the definition of a virtual function was the same - disregarding white space - as that in the parent class. That would make me feel that there was some small benefit for the insistence on 'override'.
Jan 27 2014
Steve Teale:I'm sure this was discussed at great length sometime, but yesterday (and the day before) I had one of those days where I turned on warnings , and told the compiler not to ignore deprecated things.A better compiler design is to have warning activated on default and to be disabled on request with a compiler switch. This is the enhancement request where I asked the obligatory usage of override: http://d.puremagic.com/issues/show_bug.cgi?id=3836 Bye, bearophile
Jan 27 2014
On Monday, 27 January 2014 at 16:06:46 UTC, Steve Teale wrote:But as I plodded through my code base, I came across not a single situation where the declaration of a virtual function in some derived class was an error.Based on my C++ memories it is quite common issue when working in a teams because "Big Picture" is lacking. When you are main sole contributor, keeping overall class layout in mind does not seem to be any demanding.
Jan 27 2014
Based on my C++ memories it is quite common issue when working in a teams because "Big Picture" is lacking. When you are main sole contributor, keeping overall class layout in mind does not seem to be any demanding.That is of course true. The worst case then being that other users add functions with colliding signatures without being aware of the same method in some remote base class. So yes, override has to be there, but I want my pound of flesh also ;=)
Jan 27 2014