lua-users home
lua-l archive

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


2013/11/22 Andrew Starks <andrew.starks@trms.com>:

> I've looked around for this and can't find it. It's not a big deal,
> but I find myself wanting to do
>
> t[#t + 1] = v
>
> and in C, that's actually a lot of code.

That's because quite a lot happens. The `#` operator may trigger
a metamethod, a new table entry must be created, etc.

I would write a macro so that all the ugliness goes in there and
my code would simply say

append(t,v);

Don't tell me you are too puristic for this. Many of the API functions
are actually implemented as macros.