On Tuesday, 10 November 2020 at 20:13:30 UTC, Daniel Kozak wrote:
non static nested function is a delegate, so you can just
assign it to delegate like I have posted or you can du this:
import std.stdio;
void main() {
void foo() {
writeln("It works as expected");
}
enum pfoo = &foo;
void delegate() dg;
dg.ptr = pfoo.ptr;
dg.funcptr = pfoo.funcptr;
dg();
}
I need the funcptr at *compile time*, just as I can do "enum p =
&S.foo" for a non-static member function.
I wrote "weird" not because '&' returns a delegate, but because I
was surprised that we can have enum delegates at all, given that
delegates carry a context pointer, which is not known at compile
time. That is, the enum delegate appears to be some kind of alias
of the '&' expression.
Not that the issue is critical, but it makes a library I am
writing incomplete.