[Issue 5710] cannot use delegates as parameters to non-global template

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon May 6 14:51:06 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=5710



--- Comment #18 from Steven Schveighoffer <schveiguy at yahoo.com> 2013-05-06 14:50:59 PDT ---
(In reply to comment #17)
> Kenji's solution means two context pointer delegates are just normal delegates
> (still a function pointer and a context pointer) so they can still be passed
> around as usual.

OK, but how does it devolve to a 'this' pointer for the class?  In other words,
doesn't the compiler have to treat 'this' in a special way while inside
doStuff?

Is that OK?  I guess it's not too important, but it would be a new ABI call
type, no?

I wonder if it wouldn't be better to push 'foo' and then the stack frame on to
the stack, and then the call to doStuff would look like:

uint doStuff(uint a, uint b, void* this)
{
    // *(&(this) + 0) points the object Foo
    // *(&(this) + 1) points the stack frame of main()

    //return fun(a, b);
    return fun(a, b, *(&this + 1));
}

Would that not work?  I'd actually rather just see another parameter:

uint doStuff(uint a, uint b, void *this1, void *this)
{
   return fun(a, b, this1);
}

That is simpler for me to understand, I don't see why the compiler can't do
this.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list