D
Don Taylor
Found in a style guide (http://www.artlogic.com/careers/styleguide.html)
-----------------------------------------------------------------------
Another case where "unnecessary" braces should be used is when writing
an empty while loop:
while (*p++ = *q++)
{
// this loop intentionally left empty...
}
instead of the form that is more commonly found:
while (*p++ = *q++);
By prohibiting this common loop format, we can easily check for cases
where legal (but wrong) code like:
int i = 0;
while (i++ < kLoopLimit);
{
myBuffer = 0;
}
performs a loop with no body, then executes the intended body of the
loop exactly once. Python programmers can stop chuckling now.
-----------------------------------------------------------------------
Another case where "unnecessary" braces should be used is when writing
an empty while loop:
while (*p++ = *q++)
{
// this loop intentionally left empty...
}
instead of the form that is more commonly found:
while (*p++ = *q++);
By prohibiting this common loop format, we can easily check for cases
where legal (but wrong) code like:
int i = 0;
while (i++ < kLoopLimit);
{
myBuffer = 0;
}
performs a loop with no body, then executes the intended body of the
loop exactly once. Python programmers can stop chuckling now.