[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: A proposal for arrays
- From: Dibyendu Majumdar <mobile@...>
- Date: Mon, 1 Apr 2019 19:54:51 +0100
I hesitate to propose any Lua feature as the likelihood of it being
accepted is as slim as winning a lottery. So please read this for
The topic of arrays has been discussed extensively in the past. The
proposal here is not to repeat all that, and is not a language change
proposal. Instead it is an implementation and library proposal.
First, let Lua table implementation have an internal mode - call it
fixedlength array mode. In this mode two things happen:
a) The array size is fixed and predefined, an attempt to increase
array size throws an error.
b) The hash part is disabled, i.e. an attempt to insert values into
the hash part throws an error.
We then have following table functions/properties:
table.NONE - is a special Lua value that evaluates to true, and
doesn't equal anything else, including nil
table.newarray(size) - returns an array of requested size, initialized
Some additional rules:
c) Tables created this way will have the two special flags set as above.
d) Such tables may not be used as metatables.
e) Such tables may not have __index, __newindex, __len metamethods overridden.