tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
declarations in switch statements (Re: wedges on vnd(4) patch)
On Mon, Jun 21, 2010 at 06:23:02PM -0400, Christos Zoulas wrote:
>
> Well, I find the different indentation styles typically use for the braces
> clumsy and not following the standard. Or even when they do, they cause the
> code to move too much to the right:
>
> 1. don't like the two }} at the same level
> 2. same
> 3. don't like the non-standard by 4 indent.
> 4. too much on the right.
Yeah, none of those are perfect. I use #1, except I find the default case
often doesn't need the extra braces, so the braces at the same level aren't
as visually obvious.
I guess it's a matter of how important you think it is to have the variables
declared close to where they're used. It also limits the subsequent scope
of the variable, making it easier to analyze whether or not it's used later,
or e.g. whether perhaps it should have been freed within the local block, etc.
btw, there's a 5th option that is a bit in between:
switch (c) {
int myvar;
case 'a':
myvar = somevalue;
stmt;
}
but I wouldn't recommend it b/c variable initialization on the declaration line
happens in a non-obvious way (or rather, it *doesn't* happen).
eric
Home |
Main Index |
Thread Index |
Old Index