lua-users home
lua-l archive

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


Rob Shaw wrote:
Sorry, I should correct a mistyping in the previous post, in case anyone
wants to try this. Also, " require(name) " constructs part of the key to the
registry in the form " ./name.so " for a library in the local directory.
So the reload function  should read:

function req(name)
package.unload('./'..name..'.so')
package.loadlib('./'..name..'.so','_luaopen_'..name)()
end

This will now correctly reload a local .so file loaded with "require".

Note that this only works on Linux (and maybe OSX). Does Lua have a constant or function that can give you the appropriate suffix for a native dynamic library?


--
chris marrin                ,""$,
chris@marrin.com          b`    $                             ,,.
                        mP     b'                            , 1$'
        ,.`           ,b`    ,`                              :$$'
     ,|`             mP    ,`                                       ,mm
   ,b"              b"   ,`            ,mm      m$$    ,m         ,`P$$
  m$`             ,b`  .` ,mm        ,'|$P   ,|"1$`  ,b$P       ,`  :$1
 b$`             ,$: :,`` |$$      ,`   $$` ,|` ,$$,,`"$$     .`    :$|
b$|            _m$`,:`    :$1   ,`     ,$Pm|`    `    :$$,..;"'     |$:
P$b,      _;b$$b$1"       |$$ ,`      ,$$"             ``'          $$
 ```"```'"    `"`         `""`        ""`                          ,P`
"As a general rule,don't solve puzzles that open portals to Hell"'