How to get address of a nested function?

Daniel Kozak kozzi11 at gmail.com
Tue Nov 10 20:08:09 UTC 2020


On Tue, Nov 10, 2020 at 8:50 PM Max Samukha via Digitalmars-d-learn <
digitalmars-d-learn at puremagic.com> wrote:

> On Tuesday, 10 November 2020 at 14:36:04 UTC, Steven
> Schveighoffer wrote:
>
> >>
> >> Is there a way to get a pointer to a non-static nested
> >> function?
> >
> > I don't think you can do it at compile time. You can at runtime
> > by accessing the funcptr of the delegate.
> >
> > -Steve
>
> Thanks for the reply. I will post the issue to bugzilla.
>

Why?
It works for me

import std.stdio;
void main() {
    void foo() {
        writeln("It works as expected");
    }
    enum pfoo = &foo;

    void delegate() dg = pfoo;
    dg();

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20201110/8ed5fd54/attachment.htm>


More information about the Digitalmars-d-learn mailing list