[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: varargs & table.insert()?
- From: "varol kaptan" <varol.kaptan@...>
- Date: Fri, 3 Aug 2007 12:58:10 +0100
On 8/3/07, Ketmar Dark <ketmar@ic.km.ua> wrote:
> hello, PA <petite.abeille@gmail.com>.
>
> On Fri, 3 Aug 2007 13:06:24 +0200
> PA <petite.abeille@gmail.com> wrote:
>
> > How does one generalize that to insert a value anywhere in a varargs?
> rewrite table.insert in Lua, so it will use xxx.n, not #n. something
> like:
... or ... you can compile lua 5.1.2 with LUA_COMPAT_GETN defined in
luaconf.h and you will get the old 5.0 semantics (except for the '#'
operator, which was not there anyway).
> local function NewInsert (tbl, position, value)
> if position <= tbl.n then
> for f = tbl.n, position, -1 do tbl[f+1] = tbl[f]; end;
> end;
> tbl[position] = value;
> return tbl;
> end;