lua-users home
lua-l archive

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

Le Mon 28/05/2007 à 18:25 Luís Santos à écrit:
> I have no doubt that the argument variables should be local - so they 
> won't collide with global environment. But when I am accessing my 
> caller's environment from another function, the lack of access to his 
> arguments looks kinda strange to me.

You can't.

If the function is defined in the global environment, when you do
getfenv() it returns you exactly _G. Not a copy of _G
So having access to function arguments would mean make them global
(because they would be added to _G)

As it is said, use getupvalue for that. And if it's not for debugging,
then you should think your problem another way or use the C API. But I
still thing that having access to caller's environment should be used
only for debugging (or very special cases)


Mildred       <> <>
Clef GPG :    <hkp://> ou <>
Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]