This is kind of pretty:

void log(lazy char[] dg)
{
    if (logging)
    fwritefln(logfile, dg());
}

void foo(int i)
{
    log("Entering foo() with i set to " ~ toString(i));
}

Note the lazy keyword in the definition of the log function, which tells D to only evaluate the value if needed (ie. lazily).

Nice. Smells a little like Twisted's deferred business, except different.

Via Raganwald.