On Thursday, June 06, 2013 10:42:26 Michal Minich wrote: > On Thursday, 6 June 2013 at 05:52:28 UTC, Jonathan M Davis wrote: > > 1. 'virtual' means a method is an "introducing" one. > > 2. 'override' means override with a non-final function. > > 3. 'final override' means a method overrides a base virtual > > function with a final function. > > 4. 'final' by itself and none both mean final and > > non-overriding. > > I like the 'final override', it is more natural. > > What about case when you want to introduce new final method of > the same name as already existing final method in base (c# uses > 'new' for this) > > class Base { final void foo () } > class Derived : Base { new void foo () } > > what would be in place of 'new' in D?
We could probably use new to mean the same thing, but I confess that even allowing this seems incredibly bad to me. You end up with a base class function which isn't being overidden looking like it's being overriden in a derived class. And even if it's obvious when look at Derived's declaration thanks to the new, anything which is derived from Derived would just be marked with override. So, it would be incredibly easy to think that calling Base.foo would call Derived.foo or the foo function of the class derived from Derived. So, certainly my initial reaction is to say that because Base.foo was marked with final, it shouldn't be possible for any of its derived classes to have a function with the same signature. - Jonathan M Davis