[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua libraries
- From: Roberto Ierusalimschy <rieru@...>
- Date: Tue, 29 Jan 2002 09:10:05 -0600 (CST)
On 29 Jan 2002, Victor Bogado da Silva Lins wrote:
> I would add that the loadlib should receive a logical name, I mean it
> should be
>
> loadlib ("fltk")
>
> instead of
>
> loadlib ("/xxx/yyy/liblua_fltk.so")
>
> The loading mechanism would transate the logical name "fltk" to the
> path of the library needed it could be liblua_fltk.so in a unix
> enviroment or lua_fltk.dll in windows or even something diferent like
> loading a library in a palmos enviroment that does not have files at
> all.
Another approach is to "wrap" C libraries in Lua, and then use the new
"require" function to load them. In your program, you would always write
require "libname"
without worring whether you are loading a Lua library or a C library.
For C libraries, we would put in the lib directory a Lua file like this:
loadlib("/xxx/yyy/.../...")
or even
loadlib("/xxx/yyy/.../...", "initfunc")
To adjust between diferent systems you only need to edit this small file.
Because loadlib is not portable, we should try to keep it as simple as
possible.
-- Roberto