[swift-evolution] Review for: Remove C-style for-loops with conditions and incrementers

Dmitri Gribenko gribozavr at gmail.com
Mon Dec 7 15:07:08 CST 2015


Hi,

My biggest concern with the proposal is the lack of data regarding
equivalents for existing C-style for loops.  Note that I'm not talking
about code that uses C-style for loops in cases where a superior
construct exists in Swift, for example, `for i in myArray.indices`.
I'm interested in seeing cases not covered by that.

For example, it would be good if someone took a look at "git grep 'for
var' stdlib/" and submitted a PR that converts all those loops.  If
that results in readability improvements, it would be a great PR
regardless of the decision on this proposal.

Another concern of mine is the equivalent of C-style for loops with
'continue' statements in them.  The only equivalent based on 'while' I
can think of duplicates the increment portion of the loop.

Dmitri

-- 
main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
(j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/


More information about the swift-evolution mailing list