lua-users home
lua-l archive

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


I'd like to start using Lua for configuration file uses (which I
understand was its original purpose).  The straightforward approach that
I would normally do with a simpler language is just to load the file and
then parse it directly -- items that need to be created are determined
by the parser, not by the language.

For example, in a general scripting language you would have something
like:

window a = { x = 100, y = 10 };

It would hit "window", and then have context for the parsing afterwards.

With Lua this is a bit tougher, since it has no types.  Everything is a
table.  One approach is to have the type embedded in the table, e.g.

a =
{
   type = "window",
   x = 100,
   y = 10
}

Then the calling program iterates over all tables in global space,
checks their type strings, etc.  This seems cumbersome.  The examples
generally assume you know what you're looking for, e.g. "width",
"height", "color", whereas a general configuration language that's
specifying arbitrary data for your application (like a level description
for a game) doesn't have that facility.

The "script" approach would be to actually have the Lua script call back
into the C program, e.g.

function createWindows()
   appCreateWindow( "a", 100, 10 ) -- app function previously registered
end

Comments/opinions/suggestions?

-Hook