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



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
.



Relevant Pages

  • Re: while (1) vs. for ( ;; )
    ... > What Richard might be saying, but isn't really what I think ... is that the control expression should ... > loop is never exited by the test on the loop control. ... Richard Heathfield ...
    (comp.lang.c)
  • Re: Why segfault and no NULL match in for loop?
    ... loop in search.c, the for loop never exits, even if ... If the header file is included by a single translation unit, ... Saying a ".h file is NOT a place for headers" is like saying a "house ...
    (comp.lang.c)
  • Re: Office 2003 Installation Problem
    ... Requests for assistance by email can not and will not be acknowledged. ... to install" followed by a box saying "please wait while Windows configures MS ... then goes through the same "install/configure" loop. ...
    (microsoft.public.office.setup)
  • Re: OT: Stuff that just works
    ... > Try saying "it just works" when you have ... > ya trainers tied with too big a loop in the laces and it hooks round the ...
    (uk.comp.sys.mac)
  • Re: Looping to find status
    ... Are you saying that you have 7 fields in your table, each field holding a 1, ... This might be handled in a query, using IIF() statements (untested ... a loop, but not sure how I could loop through them. ...
    (microsoft.public.access.modulesdaovba)