lua-users home
lua-l archive

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

Philippe Lhoste wrote:
> On 24/05/2007 10:51, Thomas Lauer wrote:
>> I would like to know what others have done when faced with long lists of
>> constants. (A quick search in the archives has brought no revelation.)
>> Things I consider are first and foremost ease of use (for the clients of
>> the library, not for me;-) and efficiency, space- and time-wise.
> I never looked closely at its implementation, but I recall that in Lua
> integration to SciTE, author avoided to put all the constants in the Lua
> variable space, bloating the memory use.
> Instead, all constants from the Scintilla component are defined as
> global variables, and using the __index metamethod on _G, he retrieves
> the constant on demand.
> I hope this makes sense...

In our game dev environment, we decide to do some kind of preprocessing
to limit both expensive call to C and memory use of variable.

We use a custom C parser, but this can be implemented with token-filter.

The advantage is constant are always sync with C constant value.

Hope it help.

Julien Hamaide
Engineering Coach
10Tacle Studios Belgium / Elsewhere Entertainment