Re: classInstanceSize and vtable

2014-10-24 Thread bearophile via Digitalmars-d-learn
Etienne Cimon: So what's the point of making a class or methods final? It forbids subclassing. And final methods are not virtual, so they can be inlined. Bye, bearophile

Re: classInstanceSize and vtable

2014-10-24 Thread Simen Kjaeraas via Digitalmars-d-learn
On Friday, 24 October 2014 at 00:21:52 UTC, Etienne Cimon wrote: On 2014-10-23 20:12, bearophile wrote: In D all class instances contain a pointer to the class and a monitor pointer. The table is used for run-time reflection, and for standard virtual methods like toString, etc. Bye,

classInstanceSize and vtable

2014-10-23 Thread Etienne Cimon via Digitalmars-d-learn
I'm trying to figure out the size difference between a final class and a class (which carries a vtable pointer). import std.stdio; class A { void print(){} } final class B { void print(){} } void main(){ writeln(__traits(classInstanceSize, A));

Re: classInstanceSize and vtable

2014-10-23 Thread bearophile via Digitalmars-d-learn
Etienne Cimon: I'm not sure, why does a final class carry a vtable pointer? In D all class instances contain a pointer to the class and a monitor pointer. The table is used for run-time reflection, and for standard virtual methods like toString, etc. Bye, bearophile

Re: classInstanceSize and vtable

2014-10-23 Thread Etienne Cimon via Digitalmars-d-learn
On 2014-10-23 20:12, bearophile wrote: In D all class instances contain a pointer to the class and a monitor pointer. The table is used for run-time reflection, and for standard virtual methods like toString, etc. Bye, bearophile So what's the point of making a class or methods final? Does it