[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Compiling a Pascal DLL for Lua
- From: Romulo <romuloab@...>
- Date: Fri, 4 Mar 2011 22:12:38 -0300
On Fri, Mar 4, 2011 at 21:43, luciano de souza <firstname.lastname@example.org> wrote:
> If I understood, "require" calls a function passing the name of the
> module. The return of this function is placed in package.loaded.
Yes. Something like that.
Suppose you compiled your library as "myawesomelib.dll" and your
package.cpath is "?.dll" and your open function is
package.cpath = '?.dll'
If your luaopen_myawesomelib() "returns" a table (i.e.: it leaves a
table at the top of the stack), then you can assign it to a local:
local mylib = require 'myawesomelib'
Also, package.loaded[ "myawesomelib" ] will contain the same table
aforementioned. In fact, it will hold anything your loader function
returns. You could return a string, a number, a function etc. If you
return "nil" or don't return anything at all, then it will be set to