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? As this example

~~~znested.d
void foo () { }
unittest {
   void nested () { }
   import std.stdio;
   writeln (typeof (nested).stringof);
   writeln (typeof (&nested).stringof);
   writeln (typeof (foo).stringof);
   writeln (typeof (&foo).stringof);
}
~~~

   $ dmd -unittest -checkaction=context -main -run znested.d
   pure nothrow @nogc @safe void()
   void delegate() pure nothrow @nogc @safe
   void()
   void function()
   1 unittests passed

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)

[1] https://dlang.org/spec/function.html#nested

Reply via email to