ThePhD / sol2

Sol3 (sol2 v3.0) - a C++ <-> Lua API wrapper with advanced features and top notch performance - is here, and it's great! Documentation:
http://sol2.rtfd.io/
MIT License
4.18k stars 515 forks source link

Should Sol work with Luau? #1307

Open totalgee opened 2 years ago

totalgee commented 2 years ago

I was wondering if Sol would be expected to work with Luau as well as it does with "pure" Lua. I expect to try it out in a test application at some point (and can report back here), but am wondering if anyone else has already had experience trying it?

Luau is apparently "syntactically backwards-compatible with Lua 5.1," but has some extensions with new syntax and nice things like type annotations and checking, compound assignments and more literals. It is an open-source project developed by the folks at Roblox.

ThePhD commented 2 years ago

If Luau has a C API, sure.

If it doesn't have a C API, then probably not!

totalgee commented 2 years ago

Thanks. It does seem to have a C API that is allegedly compatible with Lua 5.1...according to the README:

The runtime mostly preserves Lua 5.1 API, so existing bindings should be more or less compatible with a few caveats.

So what are those caveats? It seems to be:

Luau closely tracks that API but has a few deviations, such as the need to compile source separately (which is important to be able to deploy VM without a compiler), or lack of __gc support (use lua_newuserdatadtor instead).

I've not had a chance to try it with Sol yet, but hopefully I will in the coming weeks.

dhkatz commented 2 years ago

Doesn't appear to work so easily. I just tried to quickly compile them and got this error:

sol2\include\sol/compatibility/lua_version.hpp(40): fatal error C1083: Cannot open include file: 'lauxlib.h': No such file or directory

It appears that Luau has changed some of the API of Lua as well. I attempted to readd the lauxlib.h to Luau just to get it to compile but a ton of errors start popping up from Sol's compatibility layer.

Luau does not define any LUA_VERSION_NUM, and setting it to 5.1 causes a ton of issues still.

There's actually a whole list of changes in the Luau repo here: https://github.com/Roblox/luau/issues/251

dhkatz commented 2 years ago

Does look like someone has managed to replace their Lua 5.1/Luajit version with Luau:

https://github.com/Roblox/luau/discussions/240

From what I can tell, I'm not sure if it's viable unless someone wants to put in a ton of work. The person who got it worked stated they even had to make some changes to Luau's source afaik.

totalgee commented 2 years ago

Ah, cool, thanks for the link @dhkatz ! It does indeed look non-trivial, though...

kunitoki commented 1 year ago

https://github.com/kunitoki/LuaBridge3 is the only binder supporting lua, luajit and luau

ThePhD commented 1 year ago

Looks nice! I'll have to focus on Luau support first-thing, then. I was hoping Luau would just..... build, out of the box.

Time to fix that!

kunitoki commented 1 year ago

should be pretty easy, the only tricky thing is getting all internal and user registrations to cleanup correctly without having __gc support in metatables... quite weird they don't want to support it, but 🤷🏻‍♂️

ThePhD commented 1 year ago

....

Wait they don't provide WHAT--

kunitoki commented 1 year ago

They have a construct similar to a new taking a callable destructor, they name it lua_newuserdatadtor where you can delete the objects, but any metatable __gc will be ignored.

I have some wrapping i use in luabridge3, but in general it's quite a behaviour switch and needs some tinkering to make it work with tables https://github.com/Roblox/luau/issues/256

edunad commented 1 year ago

Any updates on this :o?

tommitytom commented 1 year ago

....

Wait they don't provide WHAT--

Given this, are we to presume this isn't going to happen? :sweat_smile:

ThePhD commented 1 year ago

Like the other 100+ issues on this repo, I actually do plan to get to work on this. This year was supposed to be my "off" year, but I instead have to fight with a second Committee-Draft ballot for C23 (which is now looking like C24 since it will take so long) and like 30 other things. I'm hoping that before December I can finally start knocking tons of stuff out, but I have not been having luck focusing on my precious sol2 baby lately... 🥲

dtabar commented 8 months ago

Would love to hear any updates on this so far @ThePhD ?

dtabar commented 8 months ago

Following up again on this?

mumin16 commented 7 months ago

me too

Nolram12345 commented 2 months ago

And another request for update :) Luau is slowly taking over the Lua world, so getting support for it would be amazing!