lua-users home
lua-l archive

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

If `luac -l` is used, it is possible to show that tables are allocated with more space instead of having to allocate more space while running. I should go probably see if my programs and stuff do this.

On Mon, Feb 20, 2017, 02:10 Daurnimator <> wrote:
On 20 February 2017 at 19:00, Dirk Laurie <> wrote:
> Would you occasionally code
>     tbl = { [1]="abc", [2]="def", k1=nil, k2=nil}
> rather than
>     tbl = {"abc","def"}
> deliberately?

Yes; this A) is a form of documentation that shows the
expected/allowed/future members of your table; and B) will preallocate
a table that will be sure to fit all the members.

I often do it in my libraries. e.g.