Frits van Bommel wrote:
Michel Fortin wrote:
<http://michelf.com/weblog/2009/some-ideas-for-dynamic-vtables-in-d/>

===
In the current vtable system, each D object begins with a monitor pointer, followed by a pointer to the vtable, followed by the object’s members.
===
Isn't it { vtable, monitor, <members> } ?

Yes.


import tango.io.Stdout;

class Foo
{
    uint i = 14;
    uint j = 10;
}

void main ()
{
    auto foo1 = new Foo;
    auto foo2 = new Foo;

    show(foo1);
    show(foo2);
}

void show (Foo foo)
{
    void** ptr = *cast(void***)&foo;
    for (int i = 0; i < foo.sizeof; i++)
    {
        Stdout.formatln("{}\t{}", i, ptr[i]);
    }
}

outputs:
0       805ec80
1       0
2       e
3       a
0       805ec80
1       0
2       e
3       a

Reply via email to