lua-users home
lua-l archive

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

> A limited solution would be to make lua_socklibopen() take an optional table
> name to insert the functions into instead of the global scope.  But this
> breaks down as soon as some other library depends on socklib and expects the
> names to be in a certain place (global).

I think that putting libraries in tables is an obvious way to imitate
modules. Example code has already been posted for loading a Lua file "into a
table" rather than into global scope; there's no reason why libraries
couldn't be treated the same way: either you load them into global scope, or
into a table. Actually, global scope is just another table.

As to libraries using each other, that's harder, given that there's no
separate compilation, nor ways of "slicing" scope (short of loading more
than one copy of a library).

But it'd certainly be nice to have support in Lua for programming in the
large, and it's surely possible without ruining small-scale scripting.

-- | maximiste, n.  pessimiste