-
|
Hi! Is there a way of removing an already loaded module? Some context: I am writing an application that relies on a Wren script. The user can edit the main Wren script that my code re-executes. When I execute the script again, I go ta compile error telling me that some variables are already declared (notably imported variables). One possibility could be to wipe out the module from the VM. However, I didn't see any public API to do that. Did I miss something? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
|
Hello! There's no public api, but you can add a function to your system class or meta or somewhere that removes the module from the vm->modules map. this means the next time import is used, it won't be already loaded, and the new code will be loaded instead. Older thread. DEF_PRIMITIVE(system_unloadModule)
{
if (!validateString(vm, args[1], "Module")) return false;
Value result = wrenMapRemoveKey(vm, vm->modules, args[1]);
RETURN_VAL(result);
} |
Beta Was this translation helpful? Give feedback.
Hello!
There's no public api, but you can add a function to your system class or meta or somewhere that removes the module from the vm->modules map. this means the next time import is used, it won't be already loaded, and the new code will be loaded instead. Older thread.