Re: enhance an array's static type by a lower length-bound.
Roedy Green wrote:
I used Pascal before I used Java. The one advantage of Java 0-based
arrays is you KNOW what the base is without having to check.
It takes a bit of a mental shift, but eventually you always think
iteration starting at 0, just as when you were a kid, you would not
start counting at anything but 1.
+1
FWIW
There are times when some sort of variable indexing scheme could be useful =
for arrays, but in Java's case they opted for simplicity, as has been menti=
oned in this thread. Arrays are not the be-all and end-all, though - you c=
an get the effects wanted with associative arrays, i.e., Maps. Thus you wi=
ll gain generics (and lose reified type), heritability, flexibility (and lo=
se notational convenience) and sparseness. You can recapture some of those=
things (e.g., notational convenience) by switching to a different JVM lang=
uage that supports, e.g., bracket notation for maps.
Some of the complaints about Java can be mitigated (and ever more so) by th=
e growing number of languages that run on the JVM. It doesn't pay for a pro=
grammer to get too locked in to any one language, but a single portable and=
evolving platform such as the JVM can really empower us.
--
Lew