if (e1) return e2; [else] s1;

Jim Miller jamiller at hpcupt1.HP.COM
Wed Mar 28 06:44:49 AEST 1990


>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?

My style is:

void foo(struct spam *bar)
{
    if (bar->bletch != NULL)
        {
	. . .
	}
     . . .
     return;
} /* foo */

which makes procedure {}  inconsistant with all my other {}'s.  However,
it's so vi's "[[" and "]]" commands can find them.  I indent the procedure
body so procedure declaration and other global declarations visually stand
out.

>
>Thanks...
>
> -Chris

You're welcome.
   jim


P.S. 

>After all, while and until
>and for are also funny ways of spelling goto...
>	Ron
 
 So is "if"  :-)
       



More information about the Comp.lang.c mailing list