lua-users home
lua-l archive

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



No, sorry, you don't make much sense (to me). :)

Why do you want the C code to bother with global names? Generally, I try to avoid that since it discourages abstraction, modularization blah-blah. I mean - that is like global variables - bad.

Better to do that stuff in Lua and just pass necessary data to C functions (as table references). If you need C code for browsing those tables (& subtables) I can provide that.

-ak


Brian Hook kirjoittaa torstaina, 6. maaliskuuta 2003, kello 22:21:

Actually what I'm doing is (I think) really simple, but since I have
yet to seriously use Lua, I'm probably doing this all wrong, like
bitflags =).

I have an API call in my framework to "set the current table" so that
I can then iterate over its members or find a member.  Since I wasn't
aware of a special table name for the globals, I would simply call
lua_getglobals() if I wanted to select the global table.

I had a fairly simple scanner that would then allow me to reference
items in C code as if it were a directory structure, e.g. if I wanted
to access foo.x.y I could specify it as:

getValue( "/foo/x/y" );

but if "foo" was already selected, I could also do:

selectTable( "x" );
getValue( "y" );

etc.

So the important bit is that sometimes I wanted to set the global
table as current, and other times I wanted to select a named table,
depending on where I was trying to search the name space.

Does this make sense?

Brian