[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: New array type? (was: 'table' as fallback for tables)
- From: Daurnimator <quae@...>
- Date: Thu, 7 Jul 2016 17:25:55 +1000
On 7 July 2016 at 17:15, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> We've had several threads and I can't without re-reading everything
> give credit where credit is due, but the following ideas for fixed-length
> tables seem to be useful enough to keep in mind.
>
> 1. The __len metafield could contain an integer, not a function.
No. You don't want a metatable per array/list/sequence
> 2. That could be used to flag the table as a fixed-length array
> that may contain nils.
> 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).
>
> This does not seem to be too large for a PowerPatch.
None of this needs to be a patch.
See http://lua-users.org/lists/lua-l/2016-06/msg00409.html
- References:
- Re: New array type? (was: 'table' as fallback for tables), Jonathan Goble
- Re: New array type? (was: 'table' as fallback for tables), Philipp Janda
- Re: New array type? (was: 'table' as fallback for tables), steve donovan
- Re: New array type? (was: 'table' as fallback for tables), Philipp Janda
- Re: New array type? (was: 'table' as fallback for tables), steve donovan
- Re: New array type? (was: 'table' as fallback for tables), Hisham
- Re: New array type? (was: 'table' as fallback for tables), steve donovan
- Re: New array type? (was: 'table' as fallback for tables), steve donovan
- Re: New array type? (was: 'table' as fallback for tables), Soni L.
- Re: New array type? (was: 'table' as fallback for tables), Tim Hill
- Re: New array type? (was: 'table' as fallback for tables), Soni L.
- Re: New array type? (was: 'table' as fallback for tables), Tim Hill
- Re: New array type? (was: 'table' as fallback for tables), Coda Highland
- Re: New array type? (was: 'table' as fallback for tables), steve donovan
- Re: New array type? (was: 'table' as fallback for tables), Dirk Laurie