Ah, you're right, a line-waste will make the nesting level visually
most perceptive. Perhaps there is also an eye-ergonomic effect of
having more separation between lines.
Actually, we use line-wasting at work. The reason I don't waste lines
at hobby projects is that I like to see as much code as possible at
once. Also, bracket matching is something which can be very much
automated, and as such I'd rather leave it to the editor. Match
blinking, autoindentation and runtime bracket balance checking does
wonders.
C
cholesky
@cholesky
0
Reputation
3
Posts
34
Profile views
0
Followers
0
Following
Best posts made by cholesky
This user hasn't posted anything yet.
Latest posts made by cholesky
-
RE: What indent style do you use?
-
RE: What indent style do you use?
You're right about the bugs, see e.g. the last line
// handle it } } } // whoops, brackets commented!
Keeping track of parenthesis (or brackets in this case) is
a known problem for lisp-ers. Good editors support
blinking of matching parenthesis/brackets, which eases
maintaining such code. -
RE: What indent style do you use?
Indentation in C/Java already shows you at which level your code is;
therefore, the choice of curly braces is rather arbitrary.
Below is a lispy style I've been fond of lately.
#define dotimes(I,N) for(int I=0; I<(N); ++I)
class HaveFunMrTA {
public:
void method(int arg) {
try {
while(sometest) {
dotimes(i, thing.length) {
if(arg == thing[i]) {
index = i;
break; }
if(test) oneliner; } } }
catch(const Exception& ex) {
// handle it } } }