(no title)
seanx | 14 years ago
The fact that for(int i = 0; i < length; i++) is nicer than for(int i = 1; i <= length; i++) is irrelevant. The c style for loop is designed to make the complex case easier while making the common case harder. It also makes some compiler optimisations impossible
A better for loop would be something like for(int i = start to end)
However with 0 based indexing you end up with e.g in delphi:
for i := 0 to count-1 ... which is an open invitation to error.
In other words, the for loop construct should not be used as an argument for or against 0 based indexing, it should be derived from the indexed used.
william42|14 years ago
And the proper for loop is "for x in n".