[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Modifying a Closure in 5.0 Alpha
- From: Edgar Toernig <froese@...>
- Date: Fri, 23 Aug 2002 00:29:10 +0200
Peter Loveday wrote:
> > > So I either need a means to add an extra value to the existing
> > > closure, or query the previously pushed function and values,
> > > then re-push it all with an extra one.
> > Use lua_pushupvalues to get all upvalues in the stack and lua_tocfunction
> > to get the C function back and then create a new closure as needed.
> I can't seem to get this to work. lua_pushupvalues() seems to return 0,
> when called with the function I'm interested in on the top of the stack.
lua_pushupvalues pushes the upvalues of the currently active C function.
And in that case it would be much easier to use
You cannot _add_ new upvalues with lua_replace but you can change them
(add some nil-upvalues initially...).
The other way would be to not change the upvalues but change the contents
of a table that the function has as an upvalue. Then you can do whatever