lua-users home
lua-l archive

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


Hi, List.

I'm writting a lua2c script for luvit project before. it used LuaJIT
currently and I want port it to PUC-Lua. but LuaJIT has a very good
feature: it can compile Lua code into a object file can linked into
your program, and you needn't add luaopen_ function to preload table,
just require "name" you can load the embedded scripts.

I want to simulate this feature in plain lua, but I find I must
generate a function to add symbols to preload table, it's great that
we have a (last) searchers in offical plain Lua, that searchs the
loaded modules name space to load a symbol.

say, we build a host program named foo.exe, and export a sym
'luaopen_foo', so we needn't put it into preload table, just require
"foo" you will load the module. or we have a bar.dll, it have
'luaopen_bar' and 'luaopen_foo' symbols, load bar module will allow
you load foo module in bar.dll, even it not register into your preload
table.

a compatible module can be written in C or Lua, and it's very easy
(both dlopen and Windows support this usage), I hope this can be added
into plain Lua, so embedded script will far more easy than before.

-- 
regards,
Xavier Wang.