lua-users home
lua-l archive

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


On 20 September 2013 18:50, Matthias Beyer <mail@beyermatthias.de> wrote:
> I have several data types defined in the kernel, which I must
> translate transparently into Lua. Can you give me some pointers what
> types are the best ones for struct, enums and unions? Can you point me
> to some pitfalls I could run into?
>
> I thought about translating struct types to objects, but I don't know
> how to translate enums and unions!?

A very good reference is Chapter 28 of Programming in Lua[1]. The best
solution will depend on the specifics, but userdata types with
metamethods seem most fitting your description. Enums are often
represented/translated as string constants, since string interning
makes it efficient enough and the resulting Lua-side API is similar to
how it would be represented in pure Lua.

[1]: http://www.lua.org/pil/contents.html#28

> If you need more information about the project or so, feel free to ask me!

I'd be interested to hear more about the project. Are you developing
it in the open? I'm working on something similar myself at the moment.

-- Craig