I have a file setting like this:
main.lua (requires 'mydir.b' and then 'b')
b.lua
mydir/
b.so (LuaJIT C module)
Basically, I do this:
function print_loaded()
for k, v in pairs(package.loaded) do print(k, v) end
end
print_loaded()
require 'mydir.b'
print_loaded()
-- This would now include 'mydir.b' instead of 'b':
local b = require 'b'
The outputs printshow that my call require 'mydir.b'sets the return value as a value package.loaded['b']as well as expected package.loaded['mydir.b']. I wanted to package.loaded['b']leave it unchanged so that I could later require 'b', and not end up with (in my opinion, wrong) cached value from mydir.b.
My question is: what is a good way to handle this?
, mydir LuaJIT , mydir.whatever , require whatever .
, : " !" . . , , .