Welcome to the Monastery PerlMonks

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

by Zen (Deacon)
 on Jun 23, 2009 at 14:47 UTC ( #774042=note: print w/replies, xml ) Need Help??

This argument by Dijkstra is silly. Yes, I said it. Doesn't matter who says it; if the argument is aesthetic, that's not a reason. Consider:

N1..Nn (N sub 1 to N sub n)

My notation is "nicer," therefore it's better? No! The offset argument is better for the 0 discussion, but in the end it comes down to the generally accepted culture of using 0. If you work in a vacuum, by all means set it to be whatever your favorite number is.
• 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 roboticus (Chancellor) on Dec 21, 2012 at 16:32 UTC

Zen:

I don't think it's silly, rather it just moves the question a bit. As you indicate, the question is merely moved to "which is the better way of expressing a range". It seems that Djikstra prefers "0 <= i < N" to "1<= i < N+1". However, he doesn't say why that's any better. I agree that it looks better, but there's another formulation "0 < i <= N" that looks just as good. Why isn't that just as good? He leaves the question open.

...roboticus

When your only tool is a hammer, all problems look like your thumb.

Create A New User
Node Status?
node history
Node Type: note [id://774042]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2018-01-21 18:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
How did you see in the new year?

Results (229 votes). Check out past polls.

Notices?