5 ms·
To a great extent, the difference between "a data structure plus a dispatch table" and "an object" is primarily in how you squint. It's certainly a form of pol
by mst 5y ago
To a great extent, the difference between "a data structure plus a dispatch table" and "an object" is primarily in how you squint.
It's certainly a form of polymorphism.
- rurban 5y agoIt's a measurable difference. OO in C++ must use double indirect vtable method calls, whilst this OO in C uses only one indirection. It's measurably faster. Objects are a bit larger though, cloning is a bit more expensive, but method calls are much faster and much easier to cache.
- aaaaaaaaaaab 5y agoI think you're misinterpreting GP's code. It is a vtable, hence the static const. There would be a pointer in each struct "instance" to this static vtable, thus the same double indirection would occcur as in C++.