lua-users home
lua-l archive

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


On 23/04/2020 13.40, Gavin Wraith wrote:
At present the only way to implement mutual recursion in Lua is to declare two local variables first within a chunk and then to define two mutually dependent functions later in that chunk with the same names.

Not true.  Arbitrary table fields, in particular global variables, work
fine.

There is no way to have mutual recursion between functions defined in
separate files, for example. But is there a way to mimic a linker, using loadfile, and then doing some patching?

If you want to avoid having to use global variables or passing a table
to both modules, you can also use `debug.upvaluejoin` to merge upvalue
references after they have been created.

-- nobody
_______________________________________________
lua-l mailing list -- lua-l@lists.lua.org
To unsubscribe send an email to lua-l-leave@lists.lua.org