-----
import std.traits;
import std.stdio;

void handler(C)(C callback)
{
    callback("John");
}

void main()
{
    auto safeCallback = (string user, string pass = "hunter2")
    {
        writefln("The password is: '%s'", pass);
    };

    handler(safeCallback);
    someOtherFunc();
}

void someOtherFunc()
{
    auto hijackPassword = (string user, string pass)
    {
        writefln("Now I know your password: '%s'", pass);
    };

    handler(hijackPassword);
}
-----

Reply via email to