lua-users home
lua-l archive

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


On Thu, Jul 7, 2016 at 9:15 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> give credit where credit is due, but the following ideas for fixed-length
> tables seem to be useful enough to keep in mind.

It seems a specialized case to me?

> 1. The __len metafield could contain an integer, not a function.

But that makes sense...

> 2. That could be used to flag the table as a fixed-length array
> that may contain nils.

OK, I see, like varargs...

> 3. Supply __newindex metamethod if you want to treat an assignment
> outside the range of a fixed-length table as an error.
> 4. This will automatically cause table.insert to be an error.
> 5. The semantics of table.insert could be revised so that in the case
> of a fixed-length table, no assigment beyond __len is made, but an
> error is signalled if the last element is not nil.
> 6. Automatic resizing of a fixed-length array could be replaced
> by doing it only on request (e.g. a function table.resize).

OK, I do see the point. This will cover most of the cases.