The current versions of Lua don't support integer numbers, only floats. (With the upcoming 5.3 this is changing, but let's ignore this.)
So, my question is: what use there is in lua_pushinteger()
? If the numbers get cast into a float, why not use lua_pushnumber()
directly?
(Please don't answer "for future compatibility with 5.3", which is a good answer for today but is an answer that otherwise doesn't satisfy my curisoty: integer support wasn't expected in the old days. I want to know the reason lua_pushinteger()
was introduced in the first place, not apologetic in hindsight.)
The explicit handling of integers in the API was introduced for documentation, performance, and correctness.
Concentrating the handling of integers explicitly inside the API allows the core to use the best conversion to and from floats; in some platforms, this can be costly if done naively. It also allows the core to check for overflow, though Lua 5.1 and 5.2 did not check this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With