why ; ?

Nick Sabalausky a at a.a
Fri May 9 11:31:01 PDT 2008


"terranium" <spam at here.lot> wrote in message 
news:g01okr$1r0c$1 at digitalmars.com...
> Michael Neumann Wrote:
>
>>    if (a) {
>>      b;
>>    }
>>
>>    if (a)
>>    {
>>      b;
>>    }
>
> and this is called a coding style :)

My preferred coding style has been:

>>    if (a)
>>    {
>>      b;
>>    }

...just because the curley braces line up. But, lately, I've been tempted by 
the compactness of:

>>    if (a) {
>>      b;
>>    }

However, (after Michael Neumann convinced me in another post) I would much 
prefer to not have to even deal with that particular coding style issue in 
the first place (Ie, Don't make me make insignificant choices. It doesn't 
matter if you put the receipt in the bag, or hand it to me: don't make me 
choose.) This eliminates the entire reason to make a decision (and keeps 
everyone using one consistent style *without* forcing anyone to "do curley 
braces THIS way"):

if (a)
  b;
  c;
end

Plus, that then opens up the ability to do something like this:

while (a)
  if (b)
    c;
    d;
  fi // Or _if, or something else
wend // or _while, or something else (but please, not "end while"...way too 
long)

I used to dislike that, but the benefit is I no longer have giant unreadable 
chunks of:

      }
    }
  }
}
// Etc..

LISCB (lost in stupid curley braces), anyone? ;)

I once saw someone that had a style of commenting the ending braces with 
what the block was. I tried to adopt that, but found that I rarely ended up 
doing it unless the language forced me to.





More information about the Digitalmars-d mailing list