lua-users home
lua-l archive

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


On Wed, Nov 10, 2021 at 9:57 AM Patrick Kurth <p.kurth@posteo.de> wrote:

> My main problem
> is that, occasingly, I have to pass objects to lua. What is the best
> way to represent a structure such as my rectangle example in C?

If "occasionally" is really what it is, then I say forget userdata and
just transform to and from what Lua understands natively, e.g., a
number, a table or a string (such as a json string). Do not let Lua
keep your "native" data floating around, and do not reference
Lua-managed data except in the interface layer. If you can, avoid
using tables that hold very few members, which can be done by a
functional interface that accepts and returns multiple values.

Cheers,
V.