Rainer Weikusat schreef op 2016-06-24 18:17:
> 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;
> }
>
> Unless there's a reason to assume that count could also be < 0, this
> would better be written as
>
> while (count) {
> putchar(' ');
> --count;
> }
Or even
while( count-- ) putchar(' ');
which I read as print `count' (possibly zero) characters without even
thinking about it.
Also it makes it clear that the return value of putchar() is ignored
even if it is EOF.
>
>> Another habit I have is to avoid a statement like:
>>
>> if (abc == 42)
>>
>> and write it as
>>
>> if (42 == abc)
>>
>> instead.
>
> That's a habit of many people who either believe to be master yoda
> ('Your sister she is') or who believe their heart-felt support for
> Nikolaus Wirth is so important that it trumps writing clear code.
Sorry, but that means your brain is not wired correctly to recognize
== as the symmetric operation that it is.
Would you be equally fuzzy about
mask = 0x42 & abc;
versus
mask = abc & 0x42;
?
<SNIP>
>
> So, program in Algol 60/ Pascal/ Modula/ Oberon or "take your := and
> shove it". The world has moved on.
Not using := but = instead is one of the biggest mistakes in c.
With Java C++ inheriting it, even Python couldn't get away from it.
With moving on you mean probably that we must accept that this mistake
can never be fixed. I for me don't give up hope.
Not trying to start a flamewar. Just demonstrating that there is a
different opinion possible regards this.
--
Suffering is the prerogative of the strong, the weak -- perish.
Albert van der Horst