[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: Fri, 1 Aug 2014 14:05:25 -0700
On Aug 1, 2014, at 11:34 AM, Coroutines <coroutines@gmail.com> wrote:
>
> Something like: table.clear(table[, mode]) -- were mode is a string
> containing either 'a' for array or 'h' for hash -- similar to __mode's
> option list in metatables. Really just a table.clear() for erasing
> everything would be nice...
>
No, you don’t mean this, you mean “array part” or “non-array part”. This is quite different from the hash vs non-hash parts, which are merely an implementation detail. In fact, even with a valid array, some of the integer key entries may be kept in the hash part. Pretty much all you can know is that for a given table, Lua may choose to keep some or all of the integral key values in the “array” part, and some or none in the hash part.
Also, as is always the case when discussing arrays, what set of keys constitutes the array part? All positive integral keys? All up to the first nil value? This has been discussed again and again here and is somewhat fluid. For example, ipairs() for 5.3 is now defined in terms of # rather than the first nil value.
—Tim