You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Support recompile lualib with custom plugin? #1502
Here is the case, I want to implement a proxy for array in luajit environment with __index and __newindex that read write data in another table.
However, luajit which is lua5.1 doesn't support __len__ipair metamethod, and length operator #, global next function, global ipairs function would return wrong result on proxy.
Then I come up with an idea that write a printer plugin that print #nextipairs into some custom implementation, but this plugin would ignore code in lualib.
I think the problem is, the plugin doesn't give user enough power to modify the compilation process, since lualib are already compiled before plugin taking over.
Sounds like this is a duplicate of #973, I still think this would be a good idea to do. However, the design is not yet clear to me, and we need to decide on what the interface for this should be.
Yes this is a duplicate, and sorry I didn't check it.
Currently, lualib are already precompiled into lua code and package in the npm package.
On user compile time, lualib just skip the compiling and use the precompiled code, and I know it is for performance reason.
What I am hoping is, there is an option to choose using precompiled lualib or not, so that the lualib code can be recompiled with user's plugin if user choose not to use precompiled code. Of course, those lualib ts source code should also be published to npm.
For example, we have code array.length compiled into #array. Now I have a plugin modify it into Len(array), and I implement this global Len function so I can call the __len metamethod if it exist.
Thus, those # length operator in lualib_bundle.lua, should also be recompiled to use Len since this is user expect.
Activity
Z3rio commentedon Oct 17, 2023
Hello, I'm sadly having some trouble understanding what you are trying to achieve.
Would it perhaps be possible for you to send a code snippet explaining it? Or a playground link.
Or try to explain it in some other way, I guess
Thank you
Perryvw commentedon Oct 17, 2023
Sounds like this is a duplicate of #973, I still think this would be a good idea to do. However, the design is not yet clear to me, and we need to decide on what the interface for this should be.
pilaoda commentedon Oct 18, 2023
Yes this is a duplicate, and sorry I didn't check it.
Currently, lualib are already precompiled into lua code and package in the npm package.
On user compile time, lualib just skip the compiling and use the precompiled code, and I know it is for performance reason.
What I am hoping is, there is an option to choose using precompiled lualib or not, so that the lualib code can be recompiled with user's plugin if user choose not to use precompiled code. Of course, those lualib ts source code should also be published to npm.
For example, we have code
array.lengthcompiled into#array. Now I have a plugin modify it intoLen(array), and I implement this globalLenfunction so I can call the__lenmetamethod if it exist.Thus, those
#length operator in lualib_bundle.lua, should also be recompiled to useLensince this is user expect.