[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: luaL_loadbuffer & lua_isfunction
- From: Peter Cawley <lua@...>
- Date: Mon, 28 Mar 2011 18:25:27 +0100
On Mon, Mar 28, 2011 at 6:18 PM, Anthony Howe <achowe+lua@snert.com> wrote:
> Lua 5.1.4
>
> I use luaL_loadbuffer() to push a chunk of code on the stack, which in turn uses lua_load. lua_load states
>
> If there are no errors, lua_load pushes the compiled chunk as
> a Lua _function_ on top of the stack.
>
> If I then do
>
> rc = lua_isfunction(L, -1);
>
> of the chunk on top of the stack, then rc is false claiming the chunk on the stack is not a function. This appears to be
> contradictory with what lua_load documentation claims is pushed to the stack.
Would you care to give a complete example? The following code prints 1 for me:
int main (int argc, char **argv) {
int rc;
lua_State *L = lua_open();
luaL_loadbuffer(L, "return 4", 8, "=test");
rc = lua_isfunction(L, -1);
printf("%d\n", rc);
lua_close(L);
}