Slow performance compared to C++, ideas?

Steven Schveighoffer schveiguy at yahoo.com
Wed Jun 5 15:37:26 PDT 2013


On Wed, 05 Jun 2013 18:32:58 -0400, Adam D. Ruppe  
<destructionator at gmail.com> wrote:

> On Wednesday, 5 June 2013 at 22:03:05 UTC, Walter Bright wrote:
>> 1. Introduce 'virtual' storage class. 'virtual' not only means a method  
>> is virtual, but it is an *introducing* virtual, i.e. it starts a new  
>> vtbl[] entry even if there's a virtual of the same name in the base  
>> classes. This means that functions marked 'virtual' do not override  
>> functions marked 'virtual'.
>
> Your upgrade path sounds generally good to me, I can live with that.
>
> But I want to clearify this #1:
>
> class A { virtual void foo(); }
> class B : A { virtual void foo(); }
>
> Error, yes? It should be "override void foo();" or "override final void  
> foo();".
>
> (override and virtual together would always be an error, correct?)
>
> Whereas:
>
> class A { virtual void foo(); }
> class B : A { virtual void foo(int); }
>
> is OK because foo(int) is a new overload, right?

No, I think it introduces a new foo.  Calling A.foo does not call B.foo.   
In other words, it hides the original implementation, there are two vtable  
entries for foo.

At least, that is how I understood the C# description from that post, and  
it seems Walter is trying to specify that.  The idea is that B probably  
defined foo before A did, and A adding foo should not break B, B didn't  
even know about A's foo.

-Steve


More information about the Digitalmars-d mailing list