[erlang-questions] beginner: why are arrays zero-based?
Richard Carlsson
richardc@REDACTED
Thu Dec 6 18:45:52 CET 2007
Jonathan Amsterdam wrote:
> I have a lot of questions, but let me start with this timely one: why
> are the new arrays in R12B zero-based? I see in the source that the
> author says it's a conscious design choice, but I don't see the
> rationale, since everything else in the language seems to be 1-based.
The point is that if you want to work a lot with indices (as opposed
to doing the odd element(N,T) now and then), 1-based indexing quickly
gets painful and is a big source of fencepost errors. I'll much rather
take a few confused beginners (and I find it very little to ask of a
programmer to remember that arrays begin at 0), than lots of annoyed
users down the line when you can't change it.
/Richard Carlsson
More information about the erlang-questions
mailing list