On 4/28/20 1:48 PM, Net wrote:
> () { ... } ();
>
> Is there a name of this kind of function in D? unnamed? anonymous?

Lambda or anonymous function.[1]

Note that the last () is not part of the definition but the execution of the function.

This idiom is used for initializing e.g. a const variable with non-trivial code as well (in C++ as well):

const a = {
    // ... some complex logic ...
    return result;
  }();

Ali

[1] I have a page that shows different syntaxes for lambda functions:

  http://ddili.org/ders/d.en/lambda.html#ix_lambda.=%3E

Reply via email to