Indentation (was Re: if (e1) return e2; [else] s1;)

Arthur B. Smith art at dinorah.wustl.edu
Tue Mar 27 23:56:06 AEST 1990


In article <1990Mar25.222115.7161 at caen.engin.umich.edu> chrisl at caen.engin.umich.edu (Chris Lang) writes:
>
>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() */
>
That is our style, also.  We have found it VERY helpful.

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

I agree.  It makes the functions easier to find, too, since they are
the only thing in column 0.

    	    -it's just an opinion-
    	        art smith  
(art at dinorah.wustl.edu      or      ...!uunet!wucs1!dinorah!art)



More information about the Comp.lang.c mailing list