One curiosity...

Francisco Olarte <[email protected]> Mon, 18 May 2026 18:50:35 +0200
Newsgroups gmane.comp.lang.lua.general
Message-ID <CA+bJJbyJnmb822WQ77YEOz2SaCpxLEX97vT5Pmhfr4ykXz8oXQ@mail.gmail.com>
While doing some C-module coding I managed to put a table at TOS and do...

  lua_rawseti(L, -1, i);

It was a finger slip, and did lead to an easily fixable bug, but it let me
wondering if this ( and some of the variants which can be coded with the
table-setting-value-popping functions ) is legal, or I just dodged a bullet
by tripping.

I mean, from a direct read of the manual if I do...

int dirty_trick(lua_State *L) {
   luaL_checktable(L,1);
   lua_setop(L,1);
   lua_rawseti(L,1,1);
   return 0;
}

I would expect just an empty stack when reaching the return, and if I call
it like....

local t={}
dirty_trick(t)

I would expect t[1]==t and nothing more.

I am not presently using it, but I am asking because if it works this way
it could simplify border-case logic in some other code I have.

Francisco Olarte.

-- 
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/CA%2BbJJbyJnmb822WQ77YEOz2SaCpxLEX97vT5Pmhfr4ykXz8oXQ%40mail.gmail.com.