[OFFTOPIC] Re: C++ in kernel (was Re: exception in a device

Nate Tuck (nate.tuck@raycer.com)
Wed, 13 Jan 1999 17:37:09 -0800


Since I've gotten so much entertainment value out of this "conversation" as
a lurker, I feel compelled to give back to the greater community.

At 04:01 AM 1/14/99 +0300, Khimenko Victor wrote:
>Are you joking or just incompetent or may be just plain stupid ?

All of us fall under one of these categories from time to time.

>Since there are virtual calls in both C++ and C sample. C++ VIRTUAL CALL
>requires one additional inevitable memory reference over C VIRTUAL CALL.
>But looks like all your brain is wasted for C++ are no more room for any
>new information.

All your examples show is that inheritance in C++ is usually implemented
with a pointer to a vtable, and that the compiler isn't quite smart enough
to figure out that you only have 1 virtual function in your class and that
it could replace the vtable ptr with the contents of the vtable ptr.

To turn your example on it's head, add another "virtual" function to your C
and C++ code. Now count the number of cycles required to copy or
initialize objects in a loop. Uh oh, looks like C is hopelessly broken, it
requires an INEVITABLE extra memory reference.

ROTFL.

nate

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/