|
Philippe Verdy wrote:
Note that that page of documentation uses an usual non-sense notation to describe the content of the local parameter named "arg" (implicitly declared in all functions):It does exist in lua. In tables one can use either ',' or ';' as separator as stated in the manual: https://www.lua.org/manual/5.2/manual.html#9, https://www.lua.org/manual/5.0/manual.html#BNF.This notation uses a semicolon in a table constructor, a syntax that does not exist in Lua.
It was used in earlier versions of lua to separate array and key-value parts. (see https://www.lua.org/manual/4.0/manual.html#BNF)It may suggest that this semicolon indicates that the key/value pair n=2 is not stored in the table itself, but in its metatable.Look at the sources. Here https://github.com/lua/lua/blob/98194db4295726069137d13b8d24fca8cbf892b6/ldo.c#L220 a normal table is created for the args table without a metatable. There is no special type for the args table nor has it only an array part.Such observation cannot be made, but if it does, then any declared function that explicitly accesses to its "arg" parameter could have to create (on function entry) a new table indexing all upvalues (including nil values), and another table to store the key/value pair with an implicit key name 'n' (here ['n'] = 2) containing the effective number of upvalues (including nil's).
Such creation of two tables would be very inefficient (stressing the garbage collector), so I suspect that instead the "arg" type is not a true "table" but behaves "like a table" in user's Lua code.
I do not comment on the further points since they build upon these wrong asumptions.
Regards,
Xmilia