lua-users home
lua-l archive

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


On Tue, Dec 04, 2012 at 07:07:43PM -0500, Thomas Harning Jr. wrote:
> On Dec 4, 2012 6:39 PM, "Daurnimator" <quae@daurnimator.com> wrote:
> >
> > On 4 December 2012 18:02, Andreas K. Foerster <list@akfoerster.de> wrote:
> > > For example:
> > >   lua -l akfavatar.utf8
> > > correctly loads the module, but it defines a global name
> > > "akfavatar.utf8",
> > > which is not accessible, since the dot is reserved for table access...
> > > I think the variable should only be "utf8" then.
> >
> > Not that it's a complete solution; but you can do _G["akfavatar.utf8"]
> > to access it.
> The more proper way to fix it,I think, would be to treat it like normal
> "require" where nested tables are constructed.  Ex: akfavatar.utf8 would be
> how you'd access the module.

That is not how require works in Lua 5.2.1. It doesn't define a global
variable at all. If the module doesn't do it, you have to assign the
result to a variable yourself.

So, maybe a syntax like "lua -l utf8=akfavatar.utf8" would be the best
solution (just thinking...). However it should stay backward compatible
when no equal sign is used.

-- 
AKFoerster <http://AKFoerster.de/>