::scr horns of a dilemma
Alaric Snell
scr@thegestalt.org
Thu, 28 Mar 2002 11:38:20 +0000
On Thursday 28 March 2002 09:37, you wrote:
> > Java is not, in general, interpreted, and OO languages are no heavier
> > than non-oo languages in any fundamental way.
>
> Not convinced. Adding a vtable to support inheritance and stuff adds a
> layer of indirection to any calls into objects. Minor, but it's
> there. At least between C and C++.
NO!
Only on virtual method calls the compiler can't optimise away, and the same
calls in a C program would be nested inside switch statements or done through
pointers anyway to get the same functionality.
Put another way:
If you are calling a method on a class, and that method is not overridden in
any subclasses, then the compiler can statically deduce which implementation
of that method to use and generate a direct call.
There is only indirection when there are actually multiple possible method
implementations to choose between. And you'd need indirection of some kind to
get the same functionality in C.
ABS
--
Alaric B. Snell
http://www.alaric-snell.com/ http://RFC.net/ http://www.warhead.org.uk/
Any sufficiently advanced technology can be emulated in software