Full closures for D

Mikola Lysenko mclysenk at mtu.edu
Mon Nov 5 11:49:19 PST 2007


I'm excited.  For the first time it is now possible to do futures in 7 lines of code:

T delegate() future(T)(lazy T expr)
{
    T res;
    auto t = new Thread({res = expr();});
    t.start;
    return { t.wait; return res; }
}


Which could then be used as follows:

auto hard_result = future( hard_expression );

// Do stuff ...

use_result(hard_result());






More information about the Digitalmars-d mailing list