Re: while (1) vs. for ( ;; )
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Tue, 30 Aug 2005 05:17:40 GMT
"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)) {
...
}
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.
.
- Follow-Ups:
- Re: while (1) vs. for ( ;; )
- From: Charlie Gordon
- Re: while (1) vs. for ( ;; )
- References:
- while (1) vs. for ( ;; )
- From: Michael B Allen
- Re: while (1) vs. for ( ;; )
- From: Chris McDonald
- Re: while (1) vs. for ( ;; )
- From: Ben Pfaff
- Re: while (1) vs. for ( ;; )
- From: Chris McDonald
- Re: while (1) vs. for ( ;; )
- From: Charlie Gordon
- Re: while (1) vs. for ( ;; )
- From: akarl
- Re: while (1) vs. for ( ;; )
- From: Charlie Gordon
- while (1) vs. for ( ;; )
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: Re: print "foo" without using ;
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|