Getting rid of dynamic polymorphism and classes
Tommi
tommitissari at hotmail.com
Sat Nov 10 10:12:28 PST 2012
On Saturday, 10 November 2012 at 09:23:40 UTC, Marco Leise wrote:
> They work like this: Each object has as a pointer to a table
> of method pointers. When you extend a class, the new method
> pointers are appended to the list and existing entries are
> replaced with overrides where you have them.
> So a virtual method 'draw()' may get slot 3 in that table and
> at runtime it is not much more than:
>
> obj.vftable[3]();
Is vftable essentially an array? So, it's just a matter of
offsetting a pointer to get access to any particular slot in the
table?
If virtual method calls are really that fast to do, then I think
the idiom in the code snippet of my first post is useless, and
the idiom they represent in that video I linked to is actually
pretty great.
Note: In order to make that video's sound bearable, you have to
cut out the highest frequencies of the sound and lower some of
the middle ones. I happened to have this "Realtek HD Audio
Manager" which made it simple. Using the "city" filter helped a
bit too. Don't know what it did.
More information about the Digitalmars-d
mailing list