[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Checking whether a shared library has been loaded
- From: Hisham <h@...>
- Date: Mon, 9 Feb 2015 13:32:05 -0200
On 9 February 2015 at 13:26, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> 2015-02-09 17:19 GMT+02:00 Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br>:
>>> > No record is kept of anything loaded with "package.loadlib".
>>>
>>> The following session strongly seems to suggest that an
>>> undocumented feature of Lua 5.3, not present in Lua 5.2,
>>> is a table in the registry keyed by the filenames of libraries
>>> loaded with "package.loadlib".
>>
>> Ah, Lua 5.3 replaced _CLIBS by an anonymous table whose key is a userdata.
>> _CLIBS is used for cleanup. It is an implementation detail and so is not
>> documented in the manual. So, yes, "package.loadlib" does record which
>> shared libraries have been loaded. See the first lines of luaopen_package:
>> http://www.lua.org/source/5.3/loadlib.c.html#luaopen_package
>> http://www.lua.org/source/5.2/loadlib.c.html#luaopen_package
>
> It would actually be quite a useful feature to have documented.
> It allows a module that mainly does some bindings to test whether
> the calling program has preloaded a possibly customized version
> of some library that it then does not need to retrieve from some
> default source.
I'm assuming Bad Things will happen if you mess with the contents of
this table, right?
-- Hisham