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



Alan Balmer said:

> On Mon, 29 Aug 2005 08:42:47 +0000 (UTC), Richard Heathfield
> <invalid@xxxxxxxxxxxxxxx> wrote:
>
>>Personally, I prefer neither choice! I would rather have the loop control
>>statement explicitly document the exit condition (unless there genuinely
>>isn't one, such as might be the case in an electronic appliance like a
>>microwave oven, where "forever" can roughly be translated as "whilst power
>>is being supplied to the appliance").
>
> It often happens that there are multiple exit conditions. Is it your
> preference to set a "get out" flag for these situations?

Yes: done = 1;

> That's my
> preference, though I don't feel strongly about it (and I'm likely to
> use multiple function returns, too, when a single return is too
> contrived.)

I'm quite unlikely to use multiple returns, although I seem to recall that I
have done so on occasion, when in a tearing hurry.

--
Richard Heathfield
"Usenet is a strange place" - dmr 29 July 1999
http://www.cpax.org.uk
Email rjh at the above domain

.



Relevant Pages

  • Re: while (1) vs. for ( ;; )
    ... I would rather have the loop control ... >>>statement explicitly document the exit condition (unless there genuinely ... I've also used a flag with multiple values, when I need to know why ... Al Balmer ...
    (comp.lang.c)
  • Re: while (1) vs. for ( ;; )
    ... >> Should there be any preference between the following logically equivalent ... >statement explicitly document the exit condition (unless there genuinely ... It often happens that there are multiple exit conditions. ... Balmer Consulting ...
    (comp.lang.c)

Quantcast