Re: while (1) vs. for ( ;; )
- From: "Charlie Gordon" <news@xxxxxxxxxxx>
- Date: Wed, 31 Aug 2005 10:02:32 +0200
"Baxter" <lbax02.spamguard@xxxxxxxxxxx> wrote in message
news:11ha0ubdt7e1g18@xxxxxxxxxxxxxxxxxxxxx
>
> Why not code it like you would read it in English:
>
> bool done = false;
> while (!done) { // while not done do
do not paraphrase code in comments.
>
> bool mainloop = true;
you probably want to make this a const
> while (mainloop) { // while mainloop do
useless comments are a pain.
> ...
>
>
> You can further document it like this:
> while (!done) { // will never be done while computer is running
why require so many words for something so simple?
How much commenting will you resort to the really complicated stuff?
> ...
>
> There's many variations on this:
>
> #define NOTDONE 1
> ...
> while (NOTDONE) {
> ...
>
> Convey your intent in English (assuming English is your first language)
wrong assumption, but irrelevant.
Simple concepts are more effectively conveyed thru standard symbols*.
Fast english readers do not spell out words, or pronounce them in their heads.
Fast code readers do not like to have to read a lot of english, because in C
punctuation conveys more meaning than words.
while (!done) looks a lot like while(done) or while (idone)
for (;;) is blatantly unambiguous.
Chqrlie.
*: this is a requirement in multicultural areas, road signs are a good example:
they are not used so much in the US, where everything is written, sometimes even
abbreviated beyond repair (what is a PED XING? where is B'WY/NY?)
.
- References:
- while (1) vs. for ( ;; )
- From: Michael B Allen
- Re: while (1) vs. for ( ;; )
- From: Tim Rentsch
- Re: while (1) vs. for ( ;; )
- From: pete
- Re: while (1) vs. for ( ;; )
- From: Tim Rentsch
- Re: while (1) vs. for ( ;; )
- From: Keith Thompson
- Re: while (1) vs. for ( ;; )
- From: Charlie Gordon
- Re: while (1) vs. for ( ;; )
- From: Baxter
- while (1) vs. for ( ;; )
- Prev by Date: Re: while (1) vs. for ( ;; )
- Next by Date: Re: confused abt file operations
- Previous by thread: Re: while (1) vs. for ( ;; )
- Next by thread: Re: while (1) vs. for ( ;; )
- Index(es):
Relevant Pages
|