[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: [ANN] Lua 5.3.0 (alpha) now available
- From: Tim Hill <drtimhill@...>
- Date: Thu, 31 Jul 2014 17:49:53 -0700
On Jul 31, 2014, at 12:42 PM, Andrew Starks <andrew.starks@trms.com> wrote:
>
> All of the information efficiently presented and present...
>
> Original:
> `Copies elements from table a1 to table a2. This function performs the equivalent to the following multiple assignment: a2[t],··· = a1[f],···,a1[e]. The default for a2 is a1. The destination range can overlap with the source range. Index f must be positive.`
More inscrutable to me is why f must be positive.
> I also agree that "table.copy" seems to suggest "any key value". Obviously its definition clears that up. "table.icopy" seems to fit "pairs" and "ipairs", but I don't mean to nitpick.
+1 for table.icopy(). However, I would guess that in actuality this is just a fast, numeric index copy not restricted to arrays/sequences (which table.icopy() name might suggest). That is, it works even with holes (nil values) in the copied range, which is implied by stating that it is equivalent to a multiple assignment statement.
> It was mentioned that "table.clear" (or similar) was likely. Was it decided that it would not be useful?
My guess here is that there is no real performance gain. There are a number of tricks table.copy() can do to optimize the copy that can’t really be coded in Lua (not saying it DOES these, just that it COULD), while a clear function in Lua is pretty much as good as a C version.
—Tim