lua-users home
lua-l archive

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



On 31-Aug-04, at 4:34 PM, Nick Trout wrote:

I think this involves some static analysis of the script during
compilation in order to import the script closure so we can call it.

Not really. A simple regex scan would do. It doesn't matter if you get
false hits, because any unused closures will be garbage collected. The
only problem would be if the regex found so many false hits that it
inserted more than the permitted number of locals into the prelude.

Again, we need the script closures. The method I was suggesting involves
one function closure (for the dispatch) and then a function name to
number substitution in a pre-processing phase (either lexical, regex or
processing Luac -l output).

It's true, you end up with closures. But they're not that big, really.
And you only end up with closures for the functions you're actually
referencing.

The only other way I could come up with of doing this without the
function name for index argument substitution is to have the dispatch
function return a closure which would then be invoked, calling the
function we want. A C or Lua function could be returned. Returning a Lua
function would create garbage (eek) and using a C function would mean 2
function calls for every Lua call (inefficient).

Creating a C closure also creates garbage, unless I'm misunderstanding
you.