On 9/29/11 11:03 PM, dsimcha wrote:
== Quote from Steven Schveighoffer ([email protected])'s article
Note that there is a workaround for 1:
DT noclosure(DT)(scope DT d) if(is(DT == delegate))
{
    return d;
}

I know, but this defeats the nice zero-boilerplate solution to getting type
inference and immutability when you want to conditionally assign one of several
values to a variable.

Does this actually work with DMD? Last time I tested (some weeks ago), this worked as intended with LDC, but DMD still allocated a heap copy of the stack frame.

I don't remember the details, and unfortunately, I didn't keep a copy of the test case, but it was something like »int foo(scope int delegate() dg) { return dg(); } int main() { int a = 42; return foo({ return a; }); }«.

David

Reply via email to