[erlang-questions] beginner: why are arrays zero-based?

David Hopwood david.hopwood@REDACTED
Thu Dec 6 21:48:30 CET 2007


Jonathan Amsterdam wrote:
> I'm an Erlang newbie, and very excited by the language.
> 
> 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.

There are objective reasons to prefer 0-based indexing:
<http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF>

> Keep in mind that Erlang is poised for rapid growth. The number of new
> users of Erlang is about to increase exponentially, and
> inconsistencies like this will make the language hard to teach and
> frustrating to learn.

There's a choice here between consistency with most other languages,
and consistency within Erlang. I can see the rationale for making new
features consistent with other languages.

-- 
David Hopwood



More information about the erlang-questions mailing list