On Friday, 29 April 2016 at 04:06:24 UTC, Adam D. Ruppe wrote:
Though I'm on the fence of ++. Sure, I like it, but when I have to use a language that doesn't have it, +=1 works just as well (I just waste a little time on the edit cycle because I always use ++ first out of habit.)

I find ++ easier to parse than += 1, because my head-parser can avoid looking at a number and remembering that number to interpret control-flow/intention :o)

I also must admit that I don't see the benefit of removing for loops. There are legitimate use-cases where you really want that numerical index, be it because you iterate two arrays of the same length simultaneously, or be it because you have to enumerate the indices anyways so might as well use them for getting an index:

for(int i = 0; i < 5; ++i)
    arr1[i] += arr2[i];

And

for(int i = 0; i < 5; ++i)
    arr[i].SetIndex(i);

My guess, not knowing Swift, is that you will now implement these in a more verbose, harder to read way using while or use some concept similar to C#s LINQ or Ds ranges to somehow automatically apply this type of functionality.
Both seem way more awkward than a normal for-loop.

Whereas I must admit I could not enumerate any benefit outside "slightly, very slightly less complex language" and "it *might* stop people from doing really complex things with the index inside the loop body, causing bugs", which imho do not outweigh the breakage + probably lost convenience in certain cases.

Reply via email to