lua-users home
lua-l archive

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



On Thu, Apr 3, 2008 at 9:00 PM, Fabien <fleutot+lua@gmail.com> wrote:
Notice that metalint can easily be turned into a smarter variable localizer, which would change references to module elements into local variables. For instance, it would add "local _table_insert = table.insert" at the beginning of the file, and change every instance of "table.insert" into a reference to the local variable. This would be much more efficient than simply adding a "local table=table".

This has been done and is available as http://metalua.luaforge.net/metalint-0.2.tgz. It will turn this:

local x = { }
-- This module declares table 'Corge', 
-- and advertises it in its .dlua interface file:
require 'corge'
table.insert(x, 'foo')
Corge.foo(x)

into the equivalent of this:

local _table_insert = table.insert
local x = { }
require 'corge' 
local _Corge_foo = Corge.foo
_table_insert(x, 'foo')
_Corge_foo(x)