lua-users home
lua-l archive

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


Jerome Vuarand wrote:
>> http://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
> 
> In this paper he says that 0-based indexing is better if you use
> convention 'a' (loops of the form 'for (i=0; i<N; ++i)'). Lua uses
> convention 'c' (loops of the form 'for (i=1; i<=N; ++i)', or in Lua 'for
> i=1,N do'), so 1-based indexing is more suited to Lua.

That is a recursive argument.  Lua uses convention "c" because it has
1-based indexing.  The choice of index base drives how you specify
ranges.  No sane language or library would mix 1-based indexing with
half-open ranges, or 0-based indexing with closed ranges.

--John