[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: table insertion [was: Lua 5.1 (work2) now available]
- From: Mark Hamburg <mhamburg@...>
- Date: Fri, 05 Nov 2004 10:01:38 -0800
I don't have a specific problem with the t[] = new_element syntax, but I do
have problems with having it be implemented via t[ nil ] because this would
mean giving up an error checking opportunity.
There are in some sense two separate issues.
1. How efficient can we make insertion? I tend to include a statement like:
local tinsert = table.insert
and then use tinsert when I need to do an insertion. This saves a few table
lookups that have nothing to do with actually doing the insertion.
2. Do we need syntactic sugar because calling a function is too complicated
for a common operation? We might also want syntactic sugar if the function
call overhead were high enough that it needed to be optimized away.
On a related note, if we don't gain metamethods for insertion, etc., I'd
like to see it remain possible to override insertion however it is
implemented. (See my discussion on protected tables:
http://lua-users.org/lists/lua-l/2004-09/msg00400.html)
Mark