lua-users home
lua-l archive

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


> Wouldn't it make sense to implement [support for require] in luac?

I've written a version of luac in Lua that suports require:
	http://www.tecgraf.puc-rio.br/~lhf/ftp/lua/5.1/luac.lua

It understands command lines such as:
	lua luac.lua x.lua y.lua -L a.lua b.lua c.lua

This creates a precompiled chunk that preloads a.lua, b.lua, c.lua and
then runs x.lua and y.lua, which may require a, b, c.

The list of modules to run and the list of modules to preload are both
optional.

Since this is a Lua program, it can be modified to suit other needs,
such as returning all values returned by x.lua and y.lua, or sending all
run-time command line args to them, etc.

For added fun, the program has no comments :-) [but you may wish to
print the fake main program that it creates to see how it works]

All feedback welcome. Enjoy.
--lhf