lua-users home
lua-l archive

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


On Sat, Sep 24, 2022 at 1:08 AM Javier Guerra Giraldez
<javier@guerrag.com> wrote:

I believe your code:

> local old_require = require
> local stateOpen = false
>
> function my_require(lib)
>     if stateOpen then
>         return old_require(lib)
>     end
>
>     if allow_list(lib) then
>         local prev_state = stateOpen
>         stateOpen = true
>         local r = old_require(lib)
>         stateOpen = prev_state
>         return r
>     end
> end

is equivalent to this code:

local old_require = require

function my_require(lib)
    if allow_list(lib) then
        local stateOpen = true
        return old_require(lib)
    end
end

And I do not see how it addresses my problem. Can you clarify?

Cheers,
V.