[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: inheritance and sub-tables
- From: steve donovan <steve.j.donovan@...>
- Date: Thu, 27 Feb 2014 07:46:58 +0200
On Thu, Feb 27, 2014 at 12:42 AM, Javier Guerra Giraldez
> second, it's a little hairsplitting and somewhat personal opinion, but
> typically I call a value an object when it carries its own type
> information. C primitive values don't, and in structs you can (and
> it's sometimes good advice), but not automatically.
That feels like a good distinction - C values are (typically) dumb,
pointers point to exactly what you've declared, as you expect them to
be laid out in the struct, modulo padding.
However, instances of a C++ class with virtual methods  do carry
type information, even if it's just a VMT. A virtual method obj->M(a)
is implemented something like the pseudo-code
obj->VMT[M_slot](obj,a) - which is not a million miles away from the
Lua definition. The difference is that 'slots' are indices into a
 "member function" is more correct, but clunky. Some would argue
that the word 'method' already includes the adjective 'virtual'.
 Standard does not dictate actually where the VMT is stored; that's
determined by the ABI (see