Mail Archives: djgpp/1997/10/09/12:45:57
sumatose AT NOSPAM DOT usa DOT net wrote:
>
> In group rec.games.programmer, Ed Beroset says...
> > While that's certainly an improvement over the single semicolon, I use
> > this instead:
> >
> > while (semaphore)
> > continue;
> >
> > "continue" is, of course a C++ keyword -- the lesser known sibling of
> > "break." It has the significant advantage that unlike either of the
> > above constructs, even a casual reader can be absolutely certain about
> > the intention of the original programmer.
>
> That's odd. I had to think for a minute about what that code was
> meant to do.
Really? I'm curious about what part of the construct you found
confusing. Was the "continue" keyword unfamiliar to you? It seems
quite completely clear to me. Perhaps adding a comment (as in the
braces version) would help:
while (semaphore)
continue; // do nothing
> In fact, I would have removed if I had found it in
> a program I worked on... Getting rid of the braces is just
> confusing
OTOH, I would look at the empty braces and ponder what the programmer
forgot to code.
> - and in fact violates the coding standards of the last
> three places I worked at. 8-)
How very odd. Do those coding standards state something like, "all
while statements shall have curly braces" or do they have some specific
prohibition against the "continue" keyword? The former I could
understand (if not actually endorse). I suppose it might make things
slightly easier for those of us who also code in Perl. :-)
Ed
- Raw text -