[comp.lang.c] _continue_ as NOP

shane@inferno.peri.com (Shane Bouslough) (02/23/91)

Consider the following single statement while loop:

	while ( actual work happens in here )
		;

I have seen _continue_ used to make the NOP semi-colon a
little less invisible:

	while ( actual work happens in here )
		continue;

What is the general consensus of this practice? Please praise,
yawn, or flame at will.

scott@bbxsda.UUCP (Scott Amspoker) (02/27/91)

In article <1991Feb22.181921.21478@inferno.peri.com> shane@inferno.peri.com (Shane Bouslough) writes:
>I have seen _continue_ used to make the NOP semi-colon a
>little less invisible:
>
>	while ( actual work happens in here )
>		continue;

Hmmmmm.  I like it.  Personally I usually use empty braces:

        while ( somethingoranother )
            {}

They tend to stand out more and look less like a mistake than a ';'.

-- 
Scott Amspoker                       | Touch the peripheral convex of every
Basis International, Albuquerque, NM | kind, then various kinds of blaming
(505) 345-5232                       | sound can be sent forth.
unmvax.cs.unm.edu!bbx!bbxsda!scott   |    - Instructions for a little box that
                                     |      blurts out obscenities.

session@uncw.UUCP (Zack C. Sessions) (02/28/91)

shane@inferno.peri.com (Shane Bouslough) writes:

>Consider the following single statement while loop:

>	while ( actual work happens in here )
>		;

>I have seen _continue_ used to make the NOP semi-colon a
>little less invisible:

>	while ( actual work happens in here )
>		continue;

>What is the general consensus of this practice? Please praise,
>yawn, or flame at will.

I don't know what any accepted standard is, but my personal
preference in this type of construct is:

	while ( actual work happens in here ) ;
	next_statement;

I actually put the semi-colon on the while (or for()) on the
same line as the while (or for()). The next statement being flush
left with the previous line should be indication enough of the
structure of the code. (IMHO)

Zack Sessions
...!ecsvax!uncw!session

gwyn@smoke.brl.mil (Doug Gwyn) (02/28/91)

In article <1991Feb22.181921.21478@inferno.peri.com> shane@inferno.peri.com (Shane Bouslough) writes:
>Consider the following single statement while loop:
>	while ( actual work happens in here )
>		;
>I have seen _continue_ used to make the NOP semi-colon a
>little less invisible:
>	while ( actual work happens in here )
>		continue;

This is merely a matter of style, so I hope it doesn't generate lots
of argument.  Every competent C programmer should be expected to be
able to deal with either form when encountered.  I personally use the
former method, which strikes me as sufficiently visible and clear.
I do NOT like usage such as
	while (condition);
where the controlled statement is practically obscured by the format.

darcy@druid.uucp (D'Arcy J.M. Cain) (03/01/91)

In article <1023@uncw.UUCP> session@uncw.UUCP (Zack C. Sessions) writes:
>	while ( actual work happens in here ) ;
>	next_statement;
>
>I actually put the semi-colon on the while (or for()) on the
>same line as the while (or for()). The next statement being flush
>left with the previous line should be indication enough of the
>structure of the code. (IMHO)

Unless your printout happens to hit a page break at that point.

-- 
D'Arcy J.M. Cain (darcy@druid)     |
D'Arcy Cain Consulting             |   There's no government
West Hill, Ontario, Canada         |   like no government!
+1 416 281 6094                    |

mikeg@c3.c3.lanl.gov (Michael P. Gerlek) (03/01/91)

In article <15343@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes:
>   >	while ( actual work happens in here )
>   >		;
>   > [...or...]
>   >	while ( actual work happens in here )
>   >		continue;
>
>   This is merely a matter of style, so I hope it doesn't generate lots
>   of argument. [...]


Yeah, but which form will optimize better?   :-) :-) :-)



-[mpg]
 mikeg@lanl.gov
 "The supercomputing language of the 90's: Object Oriented Fortran ('OOF')."