On Thursday, 14 May 2015 at 22:55:43 UTC, Ali Çehreli wrote:
Yes, it is weird but that value happens to be the address of the function. Here is another test:

import std.stdio;

void foo() pure nothrow @nogc @safe
{}

void main()
{
    void printInfo(T)(T t)
    {
        writefln("%s %s", T.stringof, t);
    }

    auto f = (){};    // <-- Why the need for () here?

    printInfo(&foo);
    printInfo(f);
    printInfo({});    // <-- No need for () here.
}

There is an inconsistency where a lambda need to be defined with empty parentheses in one context while it is just fine without in another context.

One output shows that they are all of the same type (function pointers):

void function() pure nothrow @nogc @safe 473264
void function() pure nothrow @nogc @safe 4732BC
void function() pure nothrow @nogc @safe 4732C4

Ali

Thanks. This example explains a lot. It's like echoes UFCS :)

Reply via email to