lua-users home
lua-l archive

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


Hi Andrew,

On Sat, Oct 07, 2023 at 02:36:09PM +0100, Andrew Gierth wrote:
> >>>>> "Ervin" == Ervin Hegedüs <airween@gmail.com> writes:
> 
>  Ervin> As you can see I iterate through the list twice, because I don't
>  Ervin> know how can I handle in two tables parallel.
> 
> I don't see why you think this is a problem - you can easily have
> multiple tables on the stack.

I didn't know how can I access to the tables.

But now I think based on your example:

>     lua_newtable(L);  // lineerrors
>     lua_newtable(L);  // lineerrorspos

>         lua_pushstring(L, logerr.errmsg);
>         // stack:  lineerrors \ lineerrorspos \ errmsg
>         lua_seti(L, -3, c);
>         lua_newtable(L);
>         // stack:  lineerrors \ lineerrorspos \ subtable
>         lua_pushinteger(L, *logerr.startpos);
>         lua_seti(L, -2, 1);
>         lua_pushinteger(L, *logerr.endpos);
>         lua_seti(L, -2, 1);
>         // stack:  lineerrors \ lineerrorspos \ subtable
>         lua_seti(L, -2, c);

I see how does it work (I mean the indexing).

> If you're stuck on Lua 5.1, then you can easily define lua_seti yourself
> (in terms of lua_settable and lua_insert), or rewrite as

There is no plan to support Lua 5.1.

Many thanks,


a.