On Saturday, 15 June 2019 at 17:42:04 UTC, ag0aep6g wrote:
On Saturday, 15 June 2019 at 17:24:45 UTC, user1234 wrote:
---
void foo(){writeln(__PRETTY_FUNCTION__);}

void main(string[] args)
{
    void delegate() dg;
    dg.funcptr = &foo;
    dg.ptr = null; // usually a "this" or a frame address
    dg();
}
---

because dg.ptr would be used to retrieve the offset of the locals variable used in the parent stack or the address of a class instance (the this). But this is not required at all here. The opposite way would lead to various access violation.

That only works because foo doesn't have any parameters. When you add even just one, things will go wrong.

True if was forgetting that the context is a hidden parameter...
Maybe it depends on the calling convention too ?

Reply via email to