lua-users home
lua-l archive

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


Shmuel Zeigerman writes:
> Is it planned to (optionally) honor the LUA_INIT environment variable?

This is implemented now in 0.2.1.  Perhaps switches will be added later to
customize/eliminate scaffolding code output.  Another approach to the
scaffolding code would be to write it in Lua and convert it to C with lua2c. 
The Lua interpreter (lua.c) reimplemented in Lua was uploaded today and could be
used for this[1].

I've also started work today on an optimizer that could be used in lua2c and
elsewhere.  More precisely, what is required is a type of static code analysis
or data flow analysis involving constant propagation, type propagation, partial
evaluation, etc.[2]  It would work through iterative passes through the AST,
using data primarily from lexical variable usage, to gain more and more
inferences--at least that's how it seems this will work out since I've never
done this type of thing, and I'm not sure I want to put the time in to move it
beyond proof-of-concept.  For example, if one infers that certain AST
expressions have values restricted in a certain way (e.g. a value without
metatable, a number greater than 0, a constant, a value that is either a string
or a number), then the generated code can be made more efficient, such as by
using C arithmetic operators rather than Lua C API calls.  Incidentally, part of
this can also be applied to lint-like checking (e.g. prior work in [3]) and
perhaps Perl-like taint support[4-5].  There were some comments that perhaps
this is being used at the high level of LuaJIT 2 [6-7] and that others elsewhere
were interested in it [8-9].  It seems that if such code were completed it would
have multiple applications.

[1] http://lua-users.org/wiki/LuaInterpreterInLua
[2] http://en.wikipedia.org/wiki/Compiler_optimization
[3] http://lua-users.org/wiki/LuaFish
[4] http://lua-users.org/lists/lua-l/2007-11/msg00336.html
[5] http://lua-users.org/lists/lua-l/2008-02/msg00278.html
[6] http://lua-users.org/lists/lua-l/2005-07/msg00348.html
[7] http://lua-users.org/lists/lua-l/2008-02/msg00051.html
[8] http://lua-users.org/lists/lua-l/2004-11/msg00252.html
[9] http://lua-users.org/lists/lua-l/2007-11/msg00371.html