On 01/11/2014 08:13 PM, Robert wrote:

I agree. Is the only reason to have a weak connection?

Yes. Weak connections are the only reason.

Wouldn't it be possible to find out whether the delegate context ptr
is actually an object? Not sure how to do it safely though and Interfaces slightly differ.

```d
import std.stdio;

class Foo
{
    void method() {}
}

void main()
{
    auto foo = new Foo;
    auto dg = &foo.method;
    // It's a class delegate!!!
writeln(cast(void*)foo.classinfo.__vptr, " ", ***cast(void****)dg.ptr, " ", (new ClassInfo).__vptr);
    assert(***cast(void****)dg.ptr is (new ClassInfo).__vptr);
}
```

Reply via email to