I'm not sure of the exact details, but basically, if we have a lambda function stored in some sort of global variable, ala
var my_callback = fun() {
print("hello world!");
};
Hot reloading causes the code pointed to by my_callback to be unloaded. In fact, this is probably true even for non-lambda functions. The code is unloaded and so something bad happens.
To fix this, we would want to treat regular functions as basically global variables -- values that are loaded dynamically and are re-loaded when the code reloads.
For lambda functions, it seems more involved. I think probably some sort of "location + type" hash could be used, and if a matching function can't be found, it is instead deferred to a runtime panic, perhaps? This will be especially tricky in the case of async which builds a bunch of floating functions.
I'm not sure of the exact details, but basically, if we have a lambda function stored in some sort of global variable, ala
Hot reloading causes the code pointed to by my_callback to be unloaded. In fact, this is probably true even for non-lambda functions. The code is unloaded and so something bad happens.
To fix this, we would want to treat regular functions as basically global variables -- values that are loaded dynamically and are re-loaded when the code reloads.
For lambda functions, it seems more involved. I think probably some sort of "location + type" hash could be used, and if a matching function can't be found, it is instead deferred to a runtime panic, perhaps? This will be especially tricky in the case of async which builds a bunch of floating functions.