[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Parameters with Upvalue?
- From: Luiz Henrique de Figueiredo <lhf@...>
- Date: Sun, 21 Jan 2001 21:26:48 -0200 (EDT)
>I have been trying to write functions to implement
>namespaces by overriding setglobal and getglobal.
Although this is a detail, you're not "overriding setglobal and getglobal",
but rather writing "setglobal" and "getglobal" tag methods, right?
>For some reason, in my getglobal replacement, the stack has:
>1: the string of the name of the variable
>3: the upvalue table.
>What I am wondering is why in the world this "nil" value is appearing on
>the stack in between the single parameter to getglobal and the upvalue. As
>far as I can tell, getglobal only has one parameter and one result. Is the
>"nil" a placeholder for my result?
A "getglobal" tag method normally receives 2 arguments: the name of the
global variable and the current value. In this case, it's nil because you
have set "setglobal" and "getglobal" tag methods for tga(nil).
The 3rd argument is there because your tag method is a closure.