lua-users home
lua-l archive

Re: t[] = 'syntactic sugar'

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On 19/01/2012 13.36, Leo Razoumov wrote:
t[#t+1] is more efficient. It directly translates into SETTABLE opcode
while append goes through a function call first.
Minimalistic (just for the sake of discussion):
 t[+] = val //adds parsing cost
or:
 t[++] = val //adds new operator too
or:
 t[#+] = val //(possibly cheaper in parsing?)
For a new "table append" construct to make sense beyond syntactic sugar (i.e. to save the +1 operation), I guess it would probably also require a new bytecode operator; I'm not sure it would be worth it.
--
 Enrico

AltStyle によって変換されたページ (->オリジナル) /