[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: More about packaging (fwd)
- From: Tiago Dionizio <tngd@...>
- Date: Mon, 7 Jun 2004 14:04:53 +0100 (WET DST)
On Mon, 7 Jun 2004 email@example.com wrote:
> Since the unloading seems to be an area of less agreement, I started
> with the original problem. So far, I have an implementation of
> "requirelib", just like Tiago Dionizio's "requireso", which is a better
> way of doing things than my previous approach. ("lib" seemed more
> appropriate since other systems don't know what "so" is).
> The only difference is that just like "require" uses the _LOADED table,
> "requirelib" uses the _LOADEDLIB table to cache. I made both _LOADED
> and _LOADEDLIB be weak tables to allow for garbage collection. The
> function uses the LUA_PATHLIB environment variable for a search path.
If you call this function directly, the _LOADED table would be usefull.
But personally i don't call it directly to load external libraries; i
mean, if i have a library i want to load i would create a simple lua
script (for example: 'http.lua') and from there place something like
>> http = requirelib("http", "luaopen_http")()
and later when i need to use the http library i would call
like this, the http library is only loaded once. The fact that i am
writing another lua file just for the loading doesn't bother me, also, it
hides the details on which function to call from the dynamic module.