lua-users home
lua-l archive

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


Am 27.04.2013 20:41 schröbte Dirk Laurie:
2013/4/27 Steve Litt <>:
LOL, the day I use 200 variables in one function, you should shoot me
and put me out of my misery. Long before I got to 200, just for the
wellbeing of my brain, I'd arrange them in data structures, which for
the purposes of Lua means tables suitably nested.

Not in a function, no, but in a module's main file, dead easy.

Suppose you belong to the cache-system-library-functions brigade,
then the system libraries alone can account for well over 100 slots.

Some data points (top five) from a member of the cache-system-library-functions brigade:

locals for `./lua-microscope/tests/microscope1.test.lua`: 100 (11k, test script, doesn't cache globals!) locals for `./lua/vbanim/src/vbanim.lua`: 95 (13k, script, doesn't cache globals!) locals for `./lua-microscope/src/microscope.lua`: 85 (21k, module, returns a single function, rest is local) locals for `./lua/iterators/tests/iterators.test.lua`: 80 (2.2k, test script, doesn't cache globals!, many for-loops)
locals for `./lua-annotate/src/annotate/check.lua`:	67   (24k, module)

None of my modules so far caches more than 22 globals.



local bci = require( "bci" )

assert( arg[ 1 ], "Lua filename required!" )
for _,fname in ipairs( arg ) do
  local f = assert( loadfile( fname ) )
  local h = bci.getheader( f )
  print( "locals for `"..fname.."`:", h.locals )