April 15, 2014 Function Literals | ||||
---|---|---|---|---|
| ||||
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"); }; |
April 15, 2014 Re: Function Literals | ||||
---|---|---|---|---|
| ||||
Posted in reply to Brian Schott | 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
|
Copyright © 1999-2021 by the D Language Foundation