On 2012-05-22 20:35, Steven Schveighoffer wrote:

It needs to be possible to compose delegates:

class Foo
{
void foo () {};
}

void delegate () dg;

dg.funcptr = &Foo.foo;

Error, cannot cast function of type void function(Foo this) to void
function(void *this)

dg.funcptr = cast(void function(void *this))&Foo.foo; // ok

dg.ptr = cast(void*) new Foo;
dg();

At least it needs to be possible to do that in code marked with @system.


I think it should require a cast, regardless of the @system attribute,
you are telling the type system a function that requires a Foo is now OK
to accept a void *. I don't think that's something we should accept
implicitly.

-Steve

I have no problem with a couple of case, as long as it's possible to compose delegates as above. The example was just how it works today, and an explanation of what I meant by "composing delegates". This can be of great help when interfacing with other language. I used this technique to call D methods from Objective-C.

--
/Jacob Carlborg

Reply via email to