Re: 0-based Indexing
- Posted by Greg Haberek <g.haberek at comcast.net> Jul 16, 2003
- 542 views
> I don't get it. Why do some languages use 0-based indexing? It's got to be > the dumbest thing in programming language history. Or maybe not. It actually makes a lot of sense. For example, have you ever used structures? The first element is at the address of the structure. Therefore each item would be Address + n - 1 (given that each element is 1 byte) this would cause the first element to be Address + 0, the second to be Address + 1, etc.. This is a very crude example, but I think you get the point. Get a copy of the old Win32Lib by David Cuny, and rip it apart, you'll see the way he has structures set up. The new Win32Lib uses a more automated system for stuctures so you never see any numbers. The reason Euphoria uses 1-based indexing is to make it easier to read and understand. In some languages you can even set the minimum base, like in Visual Basic, with the command "Option Base 1" (i think, it's been a while since I've used VB). ~Greg