lua-users home
lua-l archive

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


> >Out of curiosity, why does lua_newuserdata() not call lua_checkstack()
> >internally?  When calling lua_newuserdata(), isn't it quite obvious
> >that you want the result on the stack?
> >
> >- mb
> >
> >
> To my knowledge, performance.
> You should know how many stack slots you have available in your C
> code. Just call lua_checkstack with the number of slots you need at
> the beginning.

It is not only performance. lua_checkstack can raise an error, while
several "lua_push*" are currently error-free. In particular, both
lua_pushcfunction and lua_pushlightuserdata are error-free, which
allows the equivent of the old lua_cpcall.

-- Roberto