Talk:Inverted syntax: Difference between revisions

Content added Content deleted
(→‎The C example: new section)
Line 72: Line 72:


The C example is not right. <code>do {stuff} while (...)</code> is quite different from <code>while (...) {stuff}</code>, and if you treat them as the same, it's going to have consequences. For example, in the provided code itself, if you run the compiled program as <code>echo -n "" | ./a.out</code>, or press ctrl-D at the prompt, the <code>do{}while()</code> will access invalid memory and/or give a wrong answer. Don't tell readers <code>do{}while</code> is the same as <code>while{}</code>. --[[User:Ledrug|Ledrug]] 00:40, 4 September 2012 (UTC)
The C example is not right. <code>do {stuff} while (...)</code> is quite different from <code>while (...) {stuff}</code>, and if you treat them as the same, it's going to have consequences. For example, in the provided code itself, if you run the compiled program as <code>echo -n "" | ./a.out</code>, or press ctrl-D at the prompt, the <code>do{}while()</code> will access invalid memory and/or give a wrong answer. Don't tell readers <code>do{}while</code> is the same as <code>while{}</code>. --[[User:Ledrug|Ledrug]] 00:40, 4 September 2012 (UTC)

:Well, it doesn't say that do-while is the same, it only says it's the closest C comes to inverted syntax. True, it might mislead people not familiar with the language. --[[User:Oenone|Oenone]] 06:33, 5 September 2012 (UTC)