lua-users home
lua-l archive

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

Eugen-Andrei Gavriloaie wrote:
> Sorry if this is a stupid question.  But either I can't find the answer
> in the docs because of a "selective" blindness or it's not so obvious
> (I'm a newbie in Lua world). So here is the question:

Other people have actually answered your question, but you may want to
consider adopting a slightly different approach: instead of parsing your
data structure from C, you could instead parse it from Lua and inform
your C code of the data it needs that way. This might make the code
easier to handle. So either:

for index, o in ipairs(applications) do
  inform_c_of_application_type(index, o.type)


function GetApplicationType(i)
  return applications[i].type

...depending on whether you want C or Lua to own the data structures.
Either way, putting the messy bits of the code in Lua might be easier
and more reliable than trying to do it in C --- performance isn't an
issue, right?

┌─── ───── ─────
│ "I have always wished for my computer to be as easy to use as my
│ telephone; my wish has come true because I can no longer figure out
│ how to use my telephone." --- Bjarne Stroustrup

Attachment: signature.asc
Description: OpenPGP digital signature