Slow performance compared to C++, ideas?
Steven Schveighoffer
schveiguy at yahoo.com
Tue Jun 4 08:44:25 PDT 2013
On Tue, 04 Jun 2013 01:05:28 -0400, Simen Kjaeraas
<simen.kjaras at gmail.com> wrote:
> On Tue, 04 Jun 2013 06:16:45 +0200, Steven Schveighoffer
> <schveiguy at yahoo.com> wrote:
>
>> I think it is unfair to say most classes are not base classes. This
>> would mean most classes are marked as final. I don't think they are.
>> One of the main reasons to use classes in the first place is for
>> extendability.
>
> This is false. Consider this hierarchy: A->B->C, where x->y means 'x
> derives from y'. There is only one base class (A), and only one class
> that may be marked final (C). This will often be the case.
I think you mean the other way around. x->y means 'y derives from x'.
But I get your point.
However, it's an invalid point. By this logic there is exactly one base
class, Object. I think it's safe to say that way of thinking is not
productive. Any class that is not final can be a base class. The classes
it derives from are not relevant (including Object).
>> BTW, did you know you can extend a base class and simply make the
>> extension final, and now all the methods on that derived class become
>> non-virtual calls? Much easier to do than making the original base
>> virtual (Note I haven't tested this to verify, but if not, it should be
>> changed in the compiler).
>
> This does however not help one iota when you have a reference to a base
> class. This will also often be the case.
I believe this is a red herring. If you are not in control of the
creation of the object, the system may actually REQUIRE virtuality, since
the base pointer might actually be to a derived type.
-Steve
More information about the Digitalmars-d
mailing list