lua-users home
lua-l archive

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


Maybe I'm misunderstanding something, but it seems as though Lua must
maintain a symbol table internally that maps identifiers to integers or
pointers, for use in indexing tables and referring to global variables in
compiled code and so on.  IIRC Scheme treats "symbols" as a special type,
distinct from strings, which makes this idea more explicit, so that's
probably where I'm getting the idea.

If I'm correct, I'm wondering if it's possible in my host program to
access this mapping, to avoid having to maintain another symbol table for
use on the host program side.  The benefit would be speeding up variable
and table queries into Lua, and also on the host side for making fast
string equality tests for objects that need to be labeled, and for storing
labels in small fixed-size variables.  It seems kind of silly to make my
own symbol table if Lua is already doing it.

Essentially what I want is something like:

int	get_symbol_id( const char* name );
const char*	get_symbol_name( int id );
void	lua_getglobal_using_id( lua_State* L, int id );
etc.

Is there a way to do this with the existing API?  Would this be a good
addition?  Or am I asking for something that's useless, dangerous or
costly to implement?  (Or is my question unclear?)

-Thatcher