API getfenv

Returns the current environment in use by the function.
 env = getfenv(f)
==Arguments==
:;f: or - A function to retrieve the environment of, or a numeric level of a function on the call stack starting from 1.
==Returns==
:;env: - The environment assigned to the function.
==Details==
* If the environment of a function has a metatable applied with the __environment field set, this function will instead return the value assigned to that key.
* This function always returns nil if called inside a __gc finalizer.
==Patch changes==