:: Re: [DNG] Studying C as told. (For …
Página Principal
Delete this message
Reply to this message
Autor: Rainer Weikusat
Data:  
Para: dng
Assunto: Re: [DNG] Studying C as told. (For help)
Peter Olson <peabo@???> writes:
> On 2016-06-24 12:17, Rainer Weikusat wrote:
>> Peter Olson <peabo@???> writes:
>>>> On June 23, 2016 at 10:48 AM Edward Bartolo <edbarx@???> wrote:
>>>>   if (count > 0)
>>>>     while(putchar(' ') && --count);

>>>
>>> I strongly recommend using the continue statement here:
>>>
>>>       while(putchar(' ') && --count) continue;

>>
>> I and I strongly recommend against it. The continue has absolutely no
>> meaning here which means its only conceivable effect is to puzzle the
>> reader. Insofar inline documentation is desired, the way to include it
>> are comments, not technically functionless statements at whose intention
>> can only be guessed at. Better yet, use a sensible loop:
>>
>> if (count > 0) while (putchar(' ') && --count);


|
| is exactly the same as

|
| while (count > 0) {

|    putchar(' ');

|        --count;
| }

|

> I could have criticized Edward for mixing the boolean with the action,
> but that was not my point. The issue is coding style. There are
> coding styles which reduce the likelihood of writing bad code, and
> they should be encouraged. The bare semicolon -> continue is one of
> them. It has nothing at all to do with what the compiler does.


Exactly. It's all about the meaning of the code. Every bit of it has to
be read, understood and maintained(!) by someone, hence, useless code is
bad as it causes more error-prone work and erects avoidable barriers to
understanding: The meta-meaning isn't self-evident to anyone but the
original author. Anybody else has to figure it ought first.