|
On 12 Sep 2006, at 04:21, Gavin Wraith wrote:
The expression t[#t+1] does become clumsy when t is replaced by LongVerboseVariableName. However, I hope I am not spoiling the fun of syntactic neology if I point out that Lua is really strong on controlling scope and that using local variables is to be recommended. So what is wrong with do local t, x = LongVerboseVariableName, pushme_in_please t[#t+1] = x end -- do
Agreed that Lua's scoping is well implemented, but ...If you wrap the do/end sequence around each instance of the table insertion, then you're doing a lot of typing to avoid a lot of other typing. As my Grandpa would say, "That's an expensive way to save money." ;-)
If you use a local variable throughout the function scope, then not only are you doing a lot of extra typing, but you may also have to scan quite a bit of code above to find the real meaning of "t".
-Eric