lua-users home
lua-l archive

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


Even if the standard libraries do create global symbols I believe you
should be safe since you redirect reads and writes of the global table
to your proxy table (although technically I think _G would be the
proxy in this case, wouldn't it?).  As long as the standard libraries
don't try to use any of your "magic" variable names you should be safe
but just to avoid having to worry that something might go wrong and
polluting the globals table you could simply define a table of your
own and use that to access your engine's state (by defining its
__index/__newindex methods appropriately etc.).  Then instead of
writing, for instance:

somestatevar = {1, 2, 3}

if you named your table e.g. "engine" you would write:

engine.somestatevar = {1, 2, 3}

Dimitris

On Wed, Aug 15, 2012 at 9:31 PM, Luiz Henrique de Figueiredo
<lhf@tecgraf.puc-rio.br> wrote:
>> It's obvious the standard library defines the following global symbols:
>> bit32, coroutine, debug, io, math, os, package, string, table. May I
>> rely on the fact it does not define or access any other global symbols
>> behind the scene?
>
> The basic library defines many globals symbols. See
>         http://www.lua.org/manual/5.2/manual.html#6.1
>