lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

2009/11/9 Duncan Cross <>
On Mon, Nov 9, 2009 at 9:01 PM, liam mail <> wrote:
> 2009/11/9 Duncan Cross <>
>> On Mon, Nov 9, 2009 at 8:41 PM, liam mail <>
>> wrote:
>> > Duncan you are correct that in pushing the function twice they are not
>> > equal
>> > (checked using  lua_rawequal which seems strange); yet pushing the
>> > function
>> > once then using push_value whilst they are raw equal as you would expect
>> > still does not call the function.
>> My final observation in the code is another boolean/number problem
>> right at the end, when you get the result:
>> >        int result = lua_tointeger(s,-1);
>> ...this should be lua_toboolean() instead. lua_tointeger() will return
>> 0 for either boolean value.
>> -Duncan
>  Yes another good catch, unfortunately the code I posted was to verify the
> result I was seeing using binding code which was pushing and pulling
> booleans. I feel this would not stop the function being called yet have
> adjusted the code and will inline it below for fullness.

Okay, I have finally tried actually *running* the code :) In three
lines you refer to '*m_lua', instead of 's'. I changed these and it
seems to work for me.

Thank you Duncan for your time and most certainly the original bug was due to different closures.
For the record m_lua is a member of the Unit Test which I adapted to post to the list, so I tried to create a full example fo the code and therefore created the instance of lua_State inside the function and ignoring the setup method which creates m_lua.
I hang my head in shame :)