[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: setfenv, how to...
- From: "Kevin Baca" <lualist@...>
- Date: Mon, 10 Nov 2003 14:41:00 -0800
tab = setmetatable( {}, { __index = _G } )
> ... Let a function with an enviromment call another with
> other enviromment?
> Example:
> -- block
> tab = {}
> function tab.afunc()
> print("Inside tab.afunc");
> end
> 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).
>
>
> The God's Peace,
>
>
> Leandro.
>