"be consistent" PerlMonks

### Re^2: why the array index has to start at 0??

by targetsmart (Curate)
 on Jun 23, 2009 at 10:27 UTC ( #773949=note: print w/replies, xml ) Need Help??

IMO it makes much sense for the array to have the first index at 1.
we never call first as "0", we always call first as '1'. so this lead to this thinking.

Vivek
-- 'I' am not the body, 'I' am the 'soul', which has no beginning or no end, no attachment or no aversion, nothing to attain or lose.
• Comment on Re^2: why the array index has to start at 0??

Replies are listed 'Best First'.
Re^3: why the array index has to start at 0??
by ikegami (Pope) on Jun 23, 2009 at 15:17 UTC

we never call first as "0", we always call first as '1'. so this lead to this thinking.

Really?

• The first km my car drove was km 0000000 on the odometer.
• The first inch on a ruler is inch zero.
• The first century AD was century zero.
• The first raffle ticket on the spool is xxx000.

It's not exactly a foreign concept.

The first century AD was century zero.

I thought the first century A.D. was century 1, the first year of which was year 1 A.D. (with the year before being 1 B.C.), the concept of "zero" not percolating into European thought until some non-zero number of centuries later. Which is why, twenty centuries later, we are stuck with 2001 being the first year of the twenty-first century.

> the first year of which was year 1 A.D. (with the year before being 1 B.C.)

Actually the troubles arising from not having a year 0 are a very good argument for arrays starting with 0. :)

Cheers Rolf
(addicted to the Perl Programming Language and ☆☆☆☆ :)

PS: Je suis Charlie!

oops, fixed.
Re^3: why the array index has to start at 0??
by mirod (Canon) on Jun 23, 2009 at 10:38 UTC

It might make sense to you, but chances are that it won't for the maintainers of your code. Arrays in most languages I know start at index 0, I am not sure going against such a common characteristic is such a good idea.

Re^3: why the array index has to start at 0??
by Anonymous Monk on Jun 23, 2009 at 12:16 UTC
Re^3: why the array index has to start at 0??
by Anonymous Monk on Jun 24, 2009 at 07:19 UTC
On your first birthday, did you turn one or two? :D
A reply falls below the community's threshold of quality. You may see it by logging in.

Create A New User
Node Status?
node history
Node Type: note [id://773949]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (3)
As of 2020-10-29 08:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My favourite web site is:

Results (269 votes). Check out past polls.

Notices?