The human friendly version, and alluded to by the author, is foreach.
For the love of avoiding mutation, let's start pitching indexing in the dustbin of history when it comes to programming languages for general use. The fact that the justifications are coming from pointers and arrays ought to be a warning flag that we are looking backward rather than designing the future.
Foreach is used as an example of working at a higher level of abstraction than iterating over a loop like
for i = 0, i <= myarray.length - 1, i++
do foo(myarray[i])
end
I'm not suggesting that foreach is singing, dancing and all-powerful, so of course it doesn't serve for accessing arrays by position. What I am suggesting is that the syntax used for arrays was not inscribed on stone tablets upon Mount Olympus, and that
myarray.get(6) //return the sixth element
myarray.foreach('foo 6 19) //operate on part of the array
May be better abstractions for general purpose programming. Syntax should facilitate the programmer.
Fair enough, but let's not fool ourselves into thinking that pointers are going away. Sure, for higher level stuff I don't want to mess with manual memory management, but what about the massive mountain of software that all of these high level programs rely upon?
We are always going to need this stuff for certain tasks. For example, I'd love to see a simply 3x3 filter operation on an image without using indices. I am also a bit biased; I'm a systems programmer, I don't write UI's and web apps. I tend to work more in the trenches, where abstraction gets in your way almost as often as it helps you get things done more quickly.
That's why I said "splice an array" rather than "iterate", actually. Whenever I'm interviewing someone and they choose a language with a "foreach", I mentally deduct a point if they insist on iterating over an array with the C-style 3-element for loop even so.
For the love of avoiding mutation, let's start pitching indexing in the dustbin of history when it comes to programming languages for general use. The fact that the justifications are coming from pointers and arrays ought to be a warning flag that we are looking backward rather than designing the future.