openresty / luajit2

OpenResty's Branch of LuaJIT 2
https://luajit.org/luajit.html
Other
1.2k stars 193 forks source link

✨ feat: add lib struct #129

Closed xiaobiaozhao closed 2 years ago

xiaobiaozhao commented 2 years ago
  1. add lib_struct to luajit
  2. add unit test
agentzh commented 2 years ago

@xiaobiaozhao do you know that it won't get JIT compiled? Also, it should be protected by macros like LUAJIT_ENABLE_LUA52COMPAT, depending on what versions of Lua the feature is from.

But why don't you use FFI and C library to expose such features? I don't see why the pack/unpack functions must be in the LuaJIT VM core, especially when they cannot even be JIT compiled. Using FFI to call C can be JIT compiled BTW.

agentzh commented 2 years ago

In conclusion, I don't think this is a good idea at all unless you can convince Mike Pall to include this in the upstream LuaJIT (which I highly doubt due to the reasons above).

agentzh commented 2 years ago

BTW, you can use LuaJIT's FFI to do pack and unpack easily already.

xiaobiaozhao commented 2 years ago

Thx, @agentzh .