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

Markku Savela Markku.Savela at tel.vtt.fi
Tue Mar 27 16:25:38 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?

   Well, I have been using about the same style, except I indent braces
half way between code indenting points. (Chris example reformatted):

void foo(struct spam *bar)
    {
    	if (bar->bletch != NULL)
		printf("Ve haf a bletch!\n");
	else
	   {
		bar->bletch = 6;
		printf("We have one NOW!\n");
	   }
	return;
    }

    And, as I uses emacs, I don't have to ident myself, emacs C mode
does most of the work, also catches any any unbalanced braces or
parethesis very easy (when you hit <tab> and don't end up where you
expect, it's time to start looking the missing brace or parenthesis ;)

    I don't use braces unless needed, because with this style it's
very hard to make mistake (with editor C mode helping...)

--
Markku Savela                         | savela at tel.vtt.fi
Technical Research Centre of Finland  |
Telecommunications Laboratory         | Markku.Savela at vtt.fi
Otakaari 7 B, SF-02150 ESPOO, Finland | savela%vtttel at router.funet.fi 



More information about the Comp.lang.c mailing list