if (e1) return e2; [else] s1;
Chris Lang
chrisl at caen.engin.umich.edu
Mon Mar 26 08:21:00 AEST 1990
In article <7990006 at hpopd.HP.COM> daves at hpopd.HP.COM (Dave Straker) writes:
>However, Allman does this and is more consistent with single statement (no
>braces) after the 'if' line, as it has the simple rule, 'after the 'if', indent
>the following statement. It also allows the statements of a function to start
>in column 1. Look what happens if you do this with K&R or Whitesmiths:
>
>int foo()
>{
>
>if (e1)
>{
> s1;
>}
>}
>
>ouch! braces at the same level.
That reminds me to ask, what about this, which is basically my style?
void foo(struct spam *bar)
{
if (bar->bletch != NULL)
{
printf("Ve haf a bletch!\n");
} /* if */
else
{
bar->bletch = 6;
printf("We have one NOW!\n");
} /* else */
return;
} /* foo() */
The point I am most interested in is the indentation of the entire function,
including opening and closing braces. Does this strike people as possibly
confusing? I find it clearer, and consistant (ie, every sub-block gets
indented, as do its opening and closing braces). I feel the final /* foo () */
makes it obvious that we're at the end of a function, not one level in...
but what do others feel?
Thanks...
-Chris
>
>Regards,
>
>Dave (brace yourself) Straker
--
Chris Lang, University of Michigan, College of Engineering +1 313 763 1832
4622 Bursley, Ann Arbor, MI, 48109 chrisl at caen.engin.umich.edu
WORK: National Center for Manufacturing Sciences,
900 Victors Way, Suite 226, Ann Arbor, MI, 48108 +1 313 995 0300
"I hate quotations. Tell me what you know." - Ralph Waldo Emerson
More information about the Comp.lang.c
mailing list