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

Timon Gehr timon.gehr at gmx.ch
Fri Mar 9 06:29:24 PST 2012


On 03/09/2012 02:29 PM, Jos van Uden wrote:
> On 13-2-2012 15:14, 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:
>
>
> Why?

Because then you don't have to rely on the compiler to optimize away the 
unneeded context pointer parameter. It should be able to do that though. 
I don't know if DMD is.


More information about the Digitalmars-d mailing list