lua-users home
lua-l archive

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


Luiz Henrique de Figueiredo wrote:

> >I know there is a restriction when it come to string index (i.e. they
> >start at 1) but there is no such restriction on tables, so why does
> >tinsert not start at index 0?
>
> If you really want to start with zero, try
>
> t={n=-1}
> tinsert( t, "A" )
> tinsert( t, "B" )
> tinsert( t, "C" )

Do we really want to encourage this kind if thing?  Field n is supposed to
be the list length, not the index of the tail of the list.  While the
current implementation may have this behavior, it's not described by the
reference manual.  Thinking about the existence of alternate Lua
implementations someday, things like this will make it all the more
difficult.

Regards,
-John