When -code-watch flag is passed, reload all the code upon resume. #840
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
One of the biggest problems I ran into when working on my latest game jam entry was that the only way to make changes to the game state without restarting the whole game was
eval
which only takes a line at a time. I wanted to be able to reload my code and resume without wiping game state.This patch implements that; when it detects that it is in "watch" mode, it automatically reloads all the game's code when you run
resume
in the console.However, I'm not convinced that watch mode is the right way to determine whether to reload or not. For codebases that aren't written specifically to support reloading (that is, they do not preserve state in globals to keep them around between loads) resuming can act more like a full reset, which defeats the purpose of resuming; might as well just do
run
for that. So maybe another option would be to make the command take a param and only do this when someone runsresume reload
instead?I am open to other suggestions too; would love to hear your thoughts.