lua-users home
lua-l archive

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



On 20 jun 2009, at 20:24, Peter Cawley wrote:

On Sat, Jun 20, 2009 at 6:59 PM, Hans van der Meer<H.vanderMeer@uva.nl> wrote:
After which luaL_checkudata simply can become:
#define luaL_checkudata(L,A,N)\
    (!lua_isudata((L),(A),(N))||luaL_typerror((L),(A),(N)))

No it cannot, as it would not then return the address of the userdata,
and furthermore, macro arguments other than L would be used multiple
times, which is a definite no-no in the Lua core.

Sorry I did not know about the no-no. Of course that should be respected.


I would not name the new function lua_isudata, as:
1) there is already the similar sounding lua_isuserdata
2) the function can be implemented in the aux library, so it would
have luaL_ prefix
3) I'd prefer luaL_touserdata rather than luaL_isuserdata, so that it
returns the pointer or NULL rather than 1 or 0

The exact naming and/or functionality is not important to me. I will gladly leave it to others to determine what is best. That userdata can be checked without an error stop is important, I think.

Your suggestion of returning a pointer or NULL is sensible. A separate call to lua_touserdata is avoided then. (Allthough I fear that some might object that this will seduce people to use the error prone constructs: if (!(a=call())) and such ;-)

I will be happy if something of this sort will be accepted in the near future.

Hans van der Meer