[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Re[3]: unpack() behaviour not as documented
- From: Vaughan McAlley <ockegheim@...>
- Date: Fri, 26 Jun 2009 23:32:34 +1000
2009/6/26 Peter Cawley <lua@corsix.org>:
>
> table.concat (table [, sep [, i [, j]]])
>
> unpack (list [, i [, j]])
>
> Both of these functions already have optional extra arguments, i and
> j, which specify the range to operate over. By default they are 1 and
> #table, but you can pass other values.
>
> print(table.concat({unpack(t, 1, 3)}))
Touché. I'll have to read through the manual and find all the other
functions I think I know.
> Why would you want to recycle a table in the first place without
> clearing it first ? Assuming you want to avoid table creation because
> you imagine it's slow, did you benchmark it before asking for a Lua
> API change ?
I'm using table.concat for creating messages consisting of lots of
small strings. If I want to create ten messages at a time, recycling
one table would create less garbage than ten tables, and would save
clearing the table each time. All this reading the Lua list has made
me cautious about creating unnecessary tables, even if it hasn't made
me aware of optional parameters to certain functions.
Vaughan