... this makes sense at some wacky level.
For me, the semantic sense is that in a 0-based array, the length of the array can be used to represent its highest index. A D example:
import std.stdio;
void main () {
auto ra = [ 'a', 'b', 'c', 'd', 'e', ];
writefln("length of ra is %s", ra.length);
writeln();
write("A: ");
foreach (i; 0 .. ra.length) {
writef("'%s' @ index %d ", ra[i], i);
}
writeln();
write("B: ");
foreach (i, e; ra[ 0 .. $ ]) {
writef("ra[%d] == '%s' ", i, e);
}
writeln();
write("C: ");
foreach (i, e; ra) {
writef("ra[%d] == '%s' ", i, e);
}
}
Output:
C:\@Work\DMD2\posts\davido> python_to_d_1
length of ra is 5
A: 'a' @ index 0 'b' @ index 1 'c' @ index 2 'd' @ index 3 'e' @
+index 4
B: ra[0] == 'a' ra[1] == 'b' ra[2] == 'c' ra[3] == 'd' ra[4] == '
+e'
C: ra[0] == 'a' ra[1] == 'b' ra[2] == 'c' ra[3] == 'd' ra[4] == '
+e'
(The expression
ra[ 0 .. $ ] is shorthand for
ra[ 0 .. ra.length ])
Give a man a fish: <%-{-{-{-<