lua-users home
lua-l archive

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


I see. Thank you.
I remembered it(i.e _G['_G' == _G]).

Where and when should I use the recursive tables?
I think _G is a good answer to this question. :) Am I missing something?

More importantly, how to find out the table is a  recursive table or
not through C API?
I think it's a difficult since I could not acquire the name which
passes to registered C function.

For example, I register int foo_func(struct lua_State* L) to Lua
through lua_register().
I could not know the argument passed to foo_func() is a recursive
table or not when encountering `foo_func(_G)` in Lua script.

On Thu, Jan 21, 2021 at 7:30 PM Sudipto Mallick <smallick.dev@gmail.com> wrote:
>
> Example:
>
>         local t = {}
>         t.t = t
>         assert((t == t.t) and (t.t == t.t.t) and (t.t.t == t.t.t.t))
> -- and so on
>
> You remember _G, don't you?
>
>         assert(_G['_G'] == _G)
>
> --Sudipto Mallick