Default Delegate Parameter

Jesse Phillips jessekphillips+D at gmail.com
Tue Jan 26 13:49:33 PST 2010


For the following code I get the bellow error. I'm wondering if I should be reporting a bug, or if creating default delegates is correctly prevented?

.\defltdg.d(10): Error: delegate defltdg.__dgliteral3 is a nested function and cannot be accessed from main

import std.stdio;

void main() {
   take(() {writeln("Hello world");});
   take(() {});
   take();
}


void take(void delegate() dg = () {}) {
   dg();
}


More information about the Digitalmars-d-learn mailing list