lua-users home
lua-l archive

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


Hi Elias

On 19 January 2018 at 10:26, Elias Hogstvedt <eliashogstvedt@gmail.com> wrote:
> In my experience with teaching other people Lua, a lot of time is spent
> explaining the differences between tables and arrays. There’s confusion
> about the length operator, pairs vs ipairs, performance difference, holes in
> tables, etc. The entire table library also only makes sense on tables that
> are treated as arrays and causes undefined behavior when used on tables.
>
> So to solve this I would simply add an array type to Lua which would help
> distinguish between tables and arrays.

I think the Lua hybrid table/array concept is one of the defining
characteristics of Lua. Any change to that would I suspect be
unacceptable to the Lua team.

My personal view is that it would have been better to have distinct
array and table types. The syntactic simplicity of having only one way
of creating an aggregate type is of course very nice, but the price of
the simplicity in syntax is a more complex data type that is (I agree)
harder to understand and use correctly.

If you want an array type I am afraid you will have to create your own
fork of Lua or a new language.

Regards
Dibyendu