[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: metatable and closure
- From: Thomas Lavergne <thomas.lavergne@...>
- Date: Wed, 17 Apr 2002 19:18:08 +0200
I have a strange problem :
'foo' is a userdata, the 'gettable' method in his metatable was set to a
c function. When I do 'foo.bar' the gettable method return a c closure
The object is to call bar : 'foo.bar()' and all method of foo use the
same c function but with different upvalues.
But is there a difference between theses two lua codes :
"f = foo.bar; v = f()" and "v = foo.bar()"
I've made test with theses two call and obtain different result and I
don't understand why.
I suppose it's possible the bug was in the 'gettable' method, I use this
lua_pushcclosure(L, lune_call, 2);
So it return a c function with two upvalue : my userdata and the
function name, lune_call make the stuff.
But I'm not sure I can use these value on the stack for making upvalues.
Thomas Lavergne "Le vrai rêveur est celui qui rêve
de l'impossible." (Elsa Triolet)
firstname.lastname@example.org ICQ:#137121910 http://assoc.wanadoo.fr/thallium/