On Dec 2, 2009, at 7:56 PM, Geoffrey Garen wrote:
The downside is that some code can get indented too far, which is
particularly unfortunate for large switches.
We could issue a fuzzy declaration such as, "Indent case blocks,
except in situations where an unreasonable amount of code would end
up so-indented, causing readability problems".
Two examples of situations where indenting case blocks would cause
readability problems are the JavaScriptCore interpreter and, to a
lesser extent, the JavaScriptCore JIT. All of Interpreter.cpp would
suddenly be indented by an extra 4 spaces, sucking up valuable
horizontal real estate.
I believe one rule that could work is something like this:
- Indent case labels inside a switch two spaces.
- Indent actual statements inside a switch four spaces.
- In the case where a case label is followed by a block, include the
open brace on the same line as the case label and indent the matching
close brace only two spaces (but still 4 spaces for the contained
statements).
That would not cause any code to be excessively indented, but would
avoid some of the downsides of not indenting at all mentioned by Chris.
I would rather have a clear rule that makes sense in a variety of
situations than a fuzzy guideline.
Regards,
Maciej
_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev