in reply to The Zeroeth Principle
There are times where you really need an index. However, this may not be as often as you think.
In nearly all cases, you are iterating through an array:
for $i ( 0 .. $#array ) { print $array[$i]; }
But Perl (and a surprising number of other languages, particularly functional ones) provide a way to do it without the index:
for $i (@array) { print $i; }
I'm told that there are even some langauges that have no way of indexing an array at all.
So when people get into debates about 0-vs-1 array indexes, or if array names should not be pluralized so that $list[1] reads better, I must wonder how often these people are using indexes. I would argue that using a lot of indexes is a result of a coder who doesn't really know the language. If you're not using array indexes, then why do you care if the array is indexed at 0 or 1 in your particular language? Why would you care if your language has indexes at all?
One of the few places where I do use indexes is in debugging--I sometimes want to know that the error occured at a certain spot in the array. Also, I use them when parsing xSV files, since I often want a specific entry in the given row.
"There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: The Zeroeth Principle
by Anonymous Monk on Aug 26, 2004 at 09:42 UTC | |
by hardburn (Abbot) on Aug 26, 2004 at 12:34 UTC | |
by Anonymous Monk on Aug 26, 2004 at 13:00 UTC | |
by hardburn (Abbot) on Aug 26, 2004 at 13:36 UTC | |
|
Re^2: The Zeroeth Principle
by Anonymous Monk on Aug 26, 2004 at 09:47 UTC |