Re: while (1) vs. for ( ;; )
- From: Alan Balmer <albalmer@xxxxxxx>
- Date: Tue, 30 Aug 2005 14:09:37 -0700
On 30 Aug 2005 12:38:42 -0700, Tim Rentsch <txr@xxxxxxxxxxxxxxxxxxx>
wrote:
>What Richard might be saying, but isn't really what I think
>he's trying to say, is that the control expression should
>redundantly express the condition for loop exit, even if the
>loop is never exited by the test on the loop control. So
>for example,
>
> /* p != NULL; */
> while( p != NULL ){
> ...
> ...
> p = blah_blah_blah();
> if( p == NULL ) break;
> ...
> ... code that doesn't affect p ...
> }
I hope that's not what he's saying. My reaction to the above would be
"What the hell? Did the writer leave something out? Is the problem I'm
currently debugging caused by missing code which should have set p?"
If it's desirable to redundantly express the exit condition, do it in
a comment.
--
Al Balmer
Balmer Consulting
removebalmerconsultingthis@xxxxxxx
.
- References:
- while (1) vs. for ( ;; )
- From: Michael B Allen
- Re: while (1) vs. for ( ;; )
- From: Richard Heathfield
- Re: while (1) vs. for ( ;; )
- From: Tim Rentsch
- while (1) vs. for ( ;; )
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: Re: while (1) vs. for ( ;; )
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|