Braces are not Compiler-Fluff.

flint at gistdev.UUCP flint at gistdev.UUCP
Tue Jan 24 10:28:00 AEST 1989


I've used a language where the indentation is part of the semantics, and I
hate it that way.  Here is a food-for-thought comparison, I'll let you draw
your own conclusions.  First, coded using braces:

while (condition_1) {
	...
	while (condition_2) {
		...
	if (exit_condition) break;  /* indent this however you like it, it */
				    /* exits the while (condition_2)       */
		...
	}
}

/* What if you use indents instead of braces? */

while (condition_1)
	...
	while (condition_2)
		...
	if (exit_condition) break;  /* exit while (condition_1) loop */
		...

/*
An un-indented "if" would not be part of either loop, and will mark the end
of the outer while.  Indent it once (as shown) and it exits the outer
"while", marks the end of the inner while, and means that the 3rd section
of ... code is actually a new block.  Indent it twice and it will exit the
inner-most while and the third set of ... code becomes part of the inner
while loop. 
*/

Flint Pellett, Global Information Systems Technology, Inc.
1800 Woodfield Drive, Savoy, IL  61874     (217) 352-1165
INTERNET: flint%gistdev at uxc.cso.uiuc.edu
UUCP:     {uunet,pur-ee,convex}!uiucuxc!gistdev!flint



More information about the Comp.lang.c mailing list