lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



The argument isn't that it's absolutely bad for a language to have
1-based indexing.

The argument is that it's bad to MIX 1-based and 0-based indexing in
the same system, and unfortunately for Lua's design as an embeddable
and extendable language, that's exactly the case here. The vast
majority of applications that will embed Lua will use 0-based indexing
internally, and a similar majority of libraries that one might wish to
bind to Lua will also use 0-based indexing.



I think people are customized to the 0-based indexing in the context of C. But that's all about it, just a custom, and one should be restricted within the C context (because everything is more or less an offset).

A programmer could more easily fall into more serious trap if he/she mix the mindset of offset and index (e.g. using continuous block with using non-continuous data structure). I think Lua's approach, though not solving all problems (and has its own pitfall), is not by nature inferior to a universal 0-base indexing system. We would explore auxiliary pattern such as always naming parameter properly as "index" or "offset".

Dong