[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: lua_CFunction equivalence
- From: Thomas Jericke <tjericke@...>
- Date: Fri, 26 Jul 2013 06:05:36 +0000
On 07/26/2013 03:45 AM, William Ahern wrote:
I also thought it must always be 0. Because you push the c function
twice, means you have two references in the Lua world, and then you
compare the references and not the values. I don't see why Lua should
check if this C function was already pushed before at the second call of
lua_pushcfunction. It would be quite an overhead.
On Thu, Jul 25, 2013 at 08:34:35PM -0700, William Ahern wrote:
If I do
rc = lua_equal(L, -1, -2);
is the value of `rc' guaranteed to be 1 in Lua 5.1, Lua 5.2, and LuaJIT?
That is, is it part of the language that C functions without upvalues are
compared according to their C function pointer values?
D'uh. The answer is no. I abstained from checking with actual code because I
assumed it would work, but my assumption was wrong, at least for Lua 5.1.
As the manual says: lua_pushcfunction(L, f) is just a makro for
lua_pushcclosure(L, f, 0)