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
For the idea I was testing to simulate what I asked in #169 , I had to use erlang.mk's autopatch feature to export the following functions in luerl_heap.erl:
del_tstruct/2
get_tstruct/2
I think, if these are exported, it'd also be beneficial to export these:
The idea is to load a Lua file, execute the returned #funref{} and then remove it using del_tstruct/2 from the #luerl.fncs tstruct which leaves the state with only the functions defined in the luafile.
I then use get_tstruct/2 to get the #lua_func{} record of the defined functions, which allows me to access the #lua_func.anno field containing the File & Name of the function.
If you need more context on why I need this, please let me know 👍
I'm happy to submit an MR myself as long as you're comfortable with this change 😄
The text was updated successfully, but these errors were encountered:
I would sincerely recommend that you don't try to solve your problem in this way. This for at least these reasons:
#tstruct is an internal implementation detail which is not intended to be seen or accessed from the outside. It is in fact a relatively new implementation detail, only a few years old, and I will quite happily replace it with something else if/when I find a better solution.
You have to be very careful not to delete a function which is referenced by something else. This can very easily be done by mistake and can result in either crashing the system when you call a non-existent function or strange behaviour if you get a new unexpected function.
My suggestion for this problem is that after you have called the F function you call the garbage collector, luerl:gc/1 or luerl_new:gc/1, which will remove the function if it is not referenced. And also clean up any other unused data.
As you can guess I will not add those functions. 😄
For the idea I was testing to simulate what I asked in #169 , I had to use erlang.mk's autopatch feature to export the following functions in
luerl_heap.erl
:del_tstruct/2
get_tstruct/2
I think, if these are exported, it'd also be beneficial to export these:
set_tstruct/3
upd_tstruct/3
For context of how I am using these functions, please see the get_tstruct usage & del_tstruct usage 😄
The idea is to load a Lua file, execute the returned
#funref{}
and then remove it usingdel_tstruct/2
from the#luerl.fncs
tstruct which leaves the state with only the functions defined in the luafile.I then use
get_tstruct/2
to get the#lua_func{}
record of the defined functions, which allows me to access the#lua_func.anno
field containing the File & Name of the function.If you need more context on why I need this, please let me know 👍
I'm happy to submit an MR myself as long as you're comfortable with this change 😄
The text was updated successfully, but these errors were encountered: