[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: The life cycle of userdata values?
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 26 Jul 2016 13:11:02 -0300
> >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