Array start index

Nemanja Boric via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 6 10:56:58 PST 2017


On Monday, 6 February 2017 at 18:55:19 UTC, pineapple wrote:
> One reason for zero-based indexes that isn't "it's what we're 
> all used to" is that if you used one-based indexes, you would 
> be able to represent one fewer index than zero-based, since one 
> of the representable values - zero - could no longer be used to 
> represent any index.
>
> Also, it's what we're all used to, and it makes perfect sense 
> to a lot of us, and the only times in recent memory I've ever 
> made off-by-one errors were when I was trying to use Lua and 
> its one-based indexing.

Related:

https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html


More information about the Digitalmars-d-learn mailing list