Re: while (1) vs. for ( ;; )
- From: Chris McDonald <chris@xxxxxxxxxxxxxxx>
- Date: Mon, 29 Aug 2005 03:22:51 +0000 (UTC)
Ben Pfaff <blp@xxxxxxxxxxxxxxx> writes:
>Chris McDonald <chris@xxxxxxxxxxxxxxx> writes:
>> Michael B Allen <mba2000@xxxxxxxxxx> writes:
>>
>>>Should there be any preference between the following logically equivalent
>>>statements?
>>
>>> while (1) {
>>>vs.
>>> for ( ;; ) {
>>
>>>I suspect the answer is "no" but I'd like to know what the consensus is
>>>so that it doesn't blink through my mind anymore when I type it.
>>
>> Preference? Why not move on to something whose intention is clear:
>>
>> while(true) {
>In what way are the former two statements' intentions not clear?
>Both of them obviously loop "forever".
I would suggest that both while(1) and for(;;) are potentially unclear
to a person (undergrad. student) seeing C for the first time
(while assuming they haven't seen Java or C++, either).
OK, I suggest that while(true) is *clearer*.
--
Chris.
.
- Follow-Ups:
- Re: while (1) vs. for ( ;; )
- From: Charlie Gordon
- Re: while (1) vs. for ( ;; )
- From: Anton Petrusevich
- Re: while (1) vs. for ( ;; )
- From: Keith Thompson
- 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
- while (1) vs. for ( ;; )
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: Re: Is char*[] convertible to const char*[]?
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|