www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Function Literals

reply "Brian Schott" <briancschott gmail.com> writes:
Valid, but rejected by DMD:

void function() a = {writeln("a");}, b = body {writeln("b");};

Valid, but rejected by DMD:

void function() a {writeln("a");}

Invalid, accepted by DMD:

void function() a = {writeln("a");};

Invalid, accepted by DMD:

// No semicolon needed if there's only one
void function() a = {writeln("a");}

For fun, accepted by DMD:

void function() bar[](alias t)(int x, int y) = { writeln("wat"); 
};
Apr 15 2014
parent "Brian Schott" <briancschott gmail.com> writes:
On Tuesday, 15 April 2014 at 18:11:13 UTC, Brian Schott wrote:
 Invalid, accepted by DMD:

 // No semicolon needed if there's only one
 void function() a = {writeln("a");}
Sorry, disregard this one. In its place, let's use this, which is valid and rejected by DMD: void function() bar {} Decl: StorageClasses(opt) BasicType Declarator FunctionBody
Apr 15 2014