Should lua_getfield etc. return type? #382
petrihakkinen
started this conversation in
Ideas
Replies: 1 comment 1 reply
-
This seems reasonable to me - it improves our compatibility wrt API with later versions of Lua and the extra cost for users who aren't using this is hopefully insignificantly small, assuming we just use smth like |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
In later Lua versions lua_getfield, lua_rawget and similar functions return the type of the value pushed on the stack. I find this very useful, since almost always you want to check that the value has the expected type. The resulting code could be slightly more performant this way too, if majority of cases are lua_getxxx() followed by lua_type(L, -1) (one less Lua API call). A lesser point would be easier transition from Lua to Luau.
What do you think? I could work on a pull request for this.
Beta Was this translation helpful? Give feedback.
All reactions