Nested functions and their linkage type

Mike Parker aldacron at gmail.com
Sun Jan 24 02:30:37 UTC 2021


On Saturday, 23 January 2021 at 20:37:49 UTC, kdevel wrote:
> In § 19.18.7 [1] it is said that
>
>    Nested functions always have the D function linkage type.
>
> Why and for what application is that important?

I assume because of mangling. The outer function is mangled into 
the nested function's name.


>
> shows from the object with D function linkage type named 
> "nested"
> a delegate is created as soon as its address is taken. (function
> pointers are only generated from static nested functions)
>

Yes. That's documented here:

https://dlang.org/spec/function.html#closures



More information about the Digitalmars-d-learn mailing list