lua-users home
lua-l archive

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


On Wed, 18 Mar 2009 21:17:58 -0300
Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> wrote:

> > > I just can't seem to get it to work with sub modules, e.g. if I require
> > > "tek.ui" in my program.
> > 
> > Oops, this is a bug in luac.lua. I'll work on a fix. Thanks for the report.
> 
> Actually, this is more a conceptual problem than a bug. Should luac.lua
> treat file paths as (sub)module paths? The current version does not; it
> just strips the path and leaves the file name, without the extension.
> Here's a patch that makes luac.lua treat file paths as (sub)module paths:
> 
> 32c32,33
> < 	b=b..string.gsub(arg[i],"^.-([^/]+)%.lua$","t['%1']=function()end;\n")
> ---
> > 	local p=string.gsub(arg[i],"/",".")
> > 	b=b..string.gsub(p,"^.-([^/]+)%.lua$","t['%1']=function()end;\n")
> 
> but then you lose the ability to put modules anywhere in your filesytem.
> I don't see a way of having both.
> 
> It's a good thing that luac.lua is written in Lua and so is easy to customize.
> 
> I hope it helps.

Indeed, this is helpful for me. I very much depend on controlled path
names, and I even use a class loader which is triggered by accessing a
proxy table. Using luac.lua, I was able to compile a GUI application
(which depends on about 20 Lua modules) into a single lua binary:

# luac.lua test.lua -L tek/ui.lua tek/ui/class/element.lua
tek/ui/class/group.lua tek/ui/class/area.lua tek/ui/class/family.lua
tek/ui/class/gadget.lua tek/ui/class/frame.lua tek/ui/class/window.lua
tek/ui/class/drawable.lua tek/ui/class/text.lua
tek/ui/class/display.lua tek/ui/class/application.lua
tek/ui/class/theme.lua tek/ui/class/drawhook.lua tek/class/object.lua
tek/class/list.lua tek/ui/class/border.lua tek/ui/border/default.lua
# rm $(find tek/ -name "*.lua")
# lua luac.out

... and it works. Thank you very much!

- Timm

-- 
Timm S. Mueller <tmueller@schulze-mueller.de>
Schulze & Mueller GbR, Erbacher Straße 26, 64342 Seeheim-Jugenheim,
Gesellschafter: Franciska Schulze, Timm S. Mueller,
Tel. +49 6257 648853-0, http://www.schulze-mueller.de/