On 01/30/2011 10:29 PM, Nick Sabalausky wrote:
void main()
{
     void foo()
     {
        while(true)
        if(done)
        {
        }
     }
}

I'm a big fan of "stacking" flow-control statements like that whenever the
outer statements don't have anything else in their body.

Like this (stupid example):

// Draw funny design (and yes, this could be optimized better)
if(shouldRefresh)
foreach(int x; 0..width)
foreach(int y; 0..height)
if(x ^ y<  width*height / 2)
     buffer[x + y*width] = palette[(x+y) % $];

Instead of something more like:

// Draw funny design (and yes, this could be optimized better)
if(shouldRefresh)
{
     foreach(int x; 0..width)
     {
         foreach(int y; 0..height)
         {
             if(x ^ y<  width*height / 2)
                 buffer[x + y*width] = palette[(x+y) % $];
         }
     }
}


Nice idea :-) Really makes sense, imo.

Denis
--
_________________
vita es estrany
spir.wikidot.com

Reply via email to