Re: while (1) vs. for ( ;; )



"Keith Thompson" <kst-u@xxxxxxx> wrote in message
news:lnk6i4rojv.fsf@xxxxxxxxxxxxxxxxxx
> "Charlie Gordon" <news@xxxxxxxxxxx> writes:
> > "akarl" <fusionfive@xxxxxxxxx> wrote in message
> > news:glPQe.32705$d5.187496@xxxxxxxxxxxxxxxxxx
> [...]
> > You are right, but things are a bit more complicated than this: pretending
to
> > clean up the C language is doomed.
> > Just look at :
> >
> > #include <stdbool.h>
> > #include <ctype.h>
> > ...
> > while (isdigit(*s) == true) {
> > ... sometime works, sometimes not ?...
> > }
>
> That's solved by following a simple rule: never compare a value to a
> literal true or false. Comparing to true or false is both error-prone
> and useless. If an expression is a condition, just use it as a
> condition.
>
> The existence of type bool doesn't mean you can't use
>
> while (isdigit(*s)) {
> ...
> }

I just meant to stress the point, that the C language is full of traps and
pitfalls... giving it a java flavor doesn't fix them.

Chqrlie.


.



Relevant Pages

  • Re: while (1) vs. for ( ;; )
    ... > clean up the C language is doomed. ... That's solved by following a simple rule: never compare a value to a ... literal true or false. ...
    (comp.lang.c)
  • Re: Pyramidable
    ... THIS IS DOGMATISM, right ?.. ... In this case you have numerous texts to compare the ... IT APPLIES WHATEVER THE LANGUAGE ... > frequent event is not frequent or missed. ...
    (sci.archaeology)
  • Re: references about the beauty of functional programming ?
    ... Forgot to mention also that OCaml simply abandons the hash table (to ... language is a design defect in itself. ... the same process it might just depend on the algorithm in question ... not possible to compare the implementations directly. ...
    (comp.lang.functional)
  • Re: Comparing files with regular expressions
    ... that matches the exclude file from the complete file (which I'm hoping ... filehandles will be closed by Perl when it finishes processing the script. ... familiar to you than Perl or any other programming language then use that. ... you had only two sheets of paper to compare, ...
    (perl.beginners)
  • Re: I ask a question if I may
    ... language with needless vulgarity is every bit as justified as ... You don't want to read profane posts on Usenet, then use your killfile (and ... being on a crusade to clean up the language of this group since our ...
    (alt.support.stop-smoking)