Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lua_53 is missing registerFns that's present in lua_51 and luau #42

Open
nurpax opened this issue Jan 8, 2024 · 3 comments
Open

lua_53 is missing registerFns that's present in lua_51 and luau #42

nurpax opened this issue Jan 8, 2024 · 3 comments
Milestone

Comments

@nurpax
Copy link
Contributor

nurpax commented Jan 8, 2024

what the title says

@natecraddock
Copy link
Owner

registerFns is equivalent to luaL_register. This function does exist in Lua 5.2 and 5.3, but only with the compatibility module defined.

From Lua 5.2 and on, the replacement function is luaL_newlib.

The semantics of the functions are different though. The register function can optionally assign all of the functions to a name that is then registered in the global package table.

The newlib function only adds the functions to a table. It is the programmers job to do something with that table.

I'm not sure what should be done here. Because this is all in the "auxiliary" library, we could in theory introduce our own function that provides the same behavior to all versions of Lua.

@nurpax
Copy link
Contributor Author

nurpax commented Jan 12, 2024

Oh, I didn't realize that. Actually I was using registerFns to do luaL_setfuncs. This is for registrating userdata object methods into the metatable. So that's the registerFns case where libname is null.

I guess adding an implementation of setFuncs from lib54.zig would be a good choice for Luau.

@natecraddock natecraddock added this to the 0.3.0 milestone Jan 13, 2024
@natecraddock
Copy link
Owner

I just realized this is at least partially resolved as of #54.

I just tested and setFuncs now works fine in all versions of Lua. newLib does not work yet, but it is an easy fix if that is the case.

Now that all the lib files are combined I'm going to spend some time polishing the docs. #25 I'll take another look at this when I do a pass on the registration functions and see if there is anything more to be done here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants