The One-Letter Nested Function - a sample article for some kind of

F i L witte2008 at gmail.com
Fri Mar 9 23:45:36 PST 2012


On Monday, 13 February 2012 at 14:14:38 UTC, bearophile wrote:
> Zach the Mystic:
>
>> void setRandomColorPair( ref ColorPair cp )
>> {
>>     import std.random;
>>     ubyte u(int a, int b) { return cast(ubyte) uniform(a,b); }
>
> Where possible it's good to add "static" to nested functions:
>
> static ubyte u(in int a, in int b) pure nothrow { return 
> cast(ubyte) uniform(a,b); }

I sorta figured D would implicitly attribute "static" to nested 
functions if the function didn't use any variables outside it's 
scope. Is that not so? Why are you saying it's a good idea to use 
"static" exactly?




More information about the Digitalmars-d mailing list