Slow performance compared to C++, ideas?
Michal Minich
michal.minich at gmail.com
Thu Jun 6 02:16:01 PDT 2013
> On Thursday, June 06, 2013 10:42:26 Michal Minich wrote:
>> On Thursday, 6 June 2013 at 05:52:28 UTC, Jonathan M Davis
>> 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.
That can cause problem for author of base class - if he add any
final method, he can break derived classes he may not know of.
Example - if you update your external lib you are using in your
project, and it happens that new version of some base has
'search' final function added, and you happen to have fn with
same name in in your derived, you must now rename all your usages
of 'search' function... (i would be preferable if you could just
add new on in your derived class 'search').
This problems are more common in languages as C# where OOP is
more frequently used as in D. Also this issue will be more
frequent in D with final as default, because to this time virtual
method were more common - and they don't have this issue as they
have 'override' behavior. 'new' would be orthogonal to 'override'
for final functions.
virutals can be overridden
finals can be newed
I think it is very clearly explained in pasted specification in
comment
http://forum.dlang.org/post/op.wx8biyx7eav7ka@stevens-macbook-pro.local
More information about the Digitalmars-d
mailing list