Re: [ANN] lcm -- Lua Code Melder, 2026-04
mjmouse9999 <[email protected]> Thu, 23 Apr 2026 16:16:50 -0700 (PDT)
| Newsgroups | gmane.comp.lang.lua.general |
|---|---|
| Message-ID | <[email protected]> |
On Friday, April 24, 2026 at 3:22 am UTC+10 Martin Eden wrote:
> Hello list,
>
> I've updated lcm, Lua Code Melder.
>
> It's command-line tool to merge all .lua files in provided directory
> into one Lua code block.
>
> https://github.com/martin-eden/lua_code_melder
This bit of the implementation is interesting:
local add_module =
function(module_name, module_code_str)
local compiled_code = assert(load(module_code_str, module_name, 't'))
_G.package.preload[module_name] =
function(...)
return compiled_code(...)
end
end
for module_name, module_code_str in pairs(Modules) do
add_module(module_name, module_code_str)
end
I did make a combiner for the main Teal module to generate tl.lua, but it
instead just fills out package.preload directly, rather than doing separate
load(...) calls. It also scans the dependencies by looking for require
statements
(This is helped by the fact that Teal always includes the brackets)
It instead just does the following for each module in the output file:
-- module this from this.lua
package.preload["this"] = function(...)
-- contents of the this.lua file
end
https://github.com/teal-language/tl/blob/main/extras/combine.tl
However it looks like your implementation will give correct line numbers for
errors and tracebacks, which is a very nice thing to have.
> [...]
--
You received this message because you are subscribed to the Google Groups "lua-l" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion visit https://groups.google.com/d/msgid/lua-l/476c91d1-12d6-40f8-8322-3ad763b25cc5n%40googlegroups.com.