lua-users home
lua-l archive

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

... Let a function with an enviromment call another with other enviromment?
-- block
    tab = {}
    function tab.afunc()
        print("Inside tab.afunc");
    setfenv(tab.afunc, tab);
-- end block

    The code above raise an error with "attempt to call global 'print' (a
nil value)". Yes, I know that the code is trying to call tab.print, but how
to set it to call the real print? (Please, I know too that I can write
tab.print = print; but this isn't what I want).

God's Peace,