A brace vs. indentation hypothesis (was Re: Braces are not Compiler-Fluff.)
T. William Wells
bill at twwells.uucp
Sun Jan 8 17:07:46 AEST 1989
In article <196 at mstan.Morgan.COM> dff at Morgan.COM (Daniel F. Fisher) writes:
: Thus, I find "
:
: if ((p != (struct foo *)(0))
: && (p->barp != (struct bar *)(0))
: && (p->barp->type == BAR_BAZ_TYPE))
: {
: debazify(p->barp);
: saltpork(p);
: }
:
: " more readable than "
:
: if ((p != (struct foo *)(0))
: && (p->barp != (struct bar *)(0))
: && (p->barp->type == BAR_BAZ_TYPE)) {
: debazify(p->barp);
: saltpork(p);
: }
:
Agreed, but I find this even more readable:
if (p != 0 && p->barp != 0 && p->barp->type == BAR_BAZ_TYPE) {
debazify(p->barp);
saltpork(p);
}
or, if I were in an extravagant mood:
if (p != 0 && p->barp != 0
&& p->barp->type == BAR_BAZ_TYPE) {
debazify(p->barp);
saltpork(p);
}
or, possibly:
if ( p != 0
&& p->barp != 0
&& p->barp->type == BAR_BAZ_TYPE) {
debazify(p->barp);
saltpork(p);
}
Note the eight column indentation for control structure. I can then
use any indentation from two to six for continuation of the
expression; more than enough space and flexibility to make things
stand out well. Thus I don't care about the braces.
Here's a hypothesis: there is a relationship between peoples'
preference for brace placement and the amount of space they use for
indentation. My belief is that the narrower the indentation, the
greater the perceived need to make braces visible; the wider the
indentation, the greater the desire to get those pesky things out of
the way.
So, let's have a poll:
1) The number of spaces I indent is: ___ [columns]
2) The braces are important for following
the control structure or setting it off: ___ [yes/no]
Anyone who would like to respond, send to me at the address below.
I'll summarize the responses in a few days.
---
Bill
{ uunet!proxftl | novavax } !twwells!bill
More information about the Comp.lang.c
mailing list