lua-users home
lua-l archive

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


On Tue, Dec 28, 2010 at 06:16, Patrick Mc(avery
<spell_gooder_now@spellingbeewinnars.org> wrote:
> "Our global environment protection system ensures that"

> Thanks Alexander, 200K is more then I cold ever dream of, quite a feat to
> organize that I'm sure.
> If you have time could you tell me more about the
> global environment protection system?

Most of it is in public.

Run-time:

Implementation (based on Lua's etc/strict.lua):

https://github.com/lua-nucleo/lua-nucleo/blob/master/lua-nucleo/strict.lua

It requires user to explicitly declare any global symbol names that he
wants to use.

If symbols were there before strict.lua was included, they are
considered to be declared from start. A downside: this means that you
need to pre-require any 3rd party Lua modules before you include
strict.lua — 3rd party code suck at the global variable management.
(For some modules, like wsapi, this is not enough, and you have to
explicitly declare global symbols they will be using later, after
initialization.)

Offline:

Our business-logic code is generated from the DSL (generator is closed-source):

Roughly:

api:call "name"
{
  some_metadata = ...
   ....
  handler = function(context)
    .. implementation goes here...
  end
}

[We have a specific case when this extra code makes sense]

Handler bytecode is inspected for globals etc. on the generation time
using this simple thing:

https://github.com/lua-aplicado/lua-aplicado/blob/master/lua-aplicado/chunk_inspector.lua

Any known symbols used in handler are imported in the generated code
as needed, if anything that is not known is met, generation fails.

HTH,
Alexander.