Talk:While loop

Bad examples
The example given on this page is badly chosen, when the number of iterations is known a For loop is the better choice than a while loop. It is the main difference between a for and a while loop, for a while loop you do not need to know the number of iterations up-front, that is, a while loop is more powerful and the example should illustrate that. Alas, I am not knowledgeable in all ten languages presented on the page and can thus not change the example.

Perl example
Regarding "Very similar to C and C++, but the while loop could also have been written on one line:":

Why is this example used? Apparently to show off Perl's compactness compared to C and C++, except that C and C++ can do it in one line also, just as compact. That part should be deleted. —Preceding unsigned comment added by Codehead1 (talk • contribs) 19:32, 1 June 2009 (UTC)

Source code format
This was a good edit. The source code format with  on the same line is more compact and has at least as much popular support as any other format. The article should use it that way. @? Andy Dingley (talk) 20:51, 11 May 2016 (UTC)


 * "Good" is a value judgement, and popularity of this can be difficult to measure. There are many different styles! And each has its adherents, and pros and cons.
 * More important is what style should wikipedia consistently use.
 * Having a browse around, there really is no consistency on brace usage currently within wikipedia:
 * C_(programming_language)
 * C_data_types
 * C_data_types
 * C99
 * And this one C_syntax has more than one style in the one document.


 * Having programmed in C/C++ for over 3 decades, I do have my own views. But I don't want to start a code-formatting war! And I'd really like to see some consistency. I do understand the compactness argument, but I also like the consistency of open brace always on its own line (the "Allman" style), for start of function as well as start of block.
 * According to this is widely used in the MS world
 * has this "expansive" style as ANSI and ISO standard.
 * And (not necessarily a reliable source) has the "Allman"" (expansive) style as the most popular (although it did generate a massive amount of comments!)
 * And only generated controversy.
 * I was surprised that I couldn't find a wiki link to brace wars, although there should probably be some more said in this Indent_style page.
 * I'm OK with C and C++ pages being different, as they are different languages.
 * What do you think? I'm not quite up to going and updating all the C code in wikipedia...
 * How do we get a wikipedia standard?
 * peterl (talk) 08:40, 12 May 2016 (UTC)
 * TL;DR. As originally noted:
 * Both formats are used. You cannot claim that either is exceptional
 * No-one is trying to compile this, or even claim it is one particular language rather than another. Most subtle syntax issues simply don't matter here.
 * This is Wikipedia. Readability to humans does matter, but not machine-readable syntax.
 * At least two editors here have expressed a preference for the more compact form.
 * Andy Dingley (talk) 09:26, 12 May 2016 (UTC)


 * It's not really fair to reject my arguments without reading them.
 * I'm not claiming either is exceptional. And there's more than two.
 * I'm not claiming anyone is trying to compile the code.
 * I agree. Readability to humans does matter. It is of considerable debate which is more readable to humans.
 * Two editors out of the millions programming C and the millions editing wikipedia doesn't make consensus.
 * peterl (talk) 23:58, 12 May 2016 (UTC)

bash - while loop, additional hints
following statements have the same meaning: "while true;"   =    "while : ;"  — Preceding unsigned comment added by 89.15.238.175 (talk) 07:04, 30 September 2019 (UTC)