4 ms·
In Python and Julia in most of the cases you have to restart ; don't know about R. In Common Lisp you can change a function that is running a loop while the loo
by register 4y ago
In Python and Julia in most of the cases you have to restart ; don't know about R. In Common Lisp you can change a function that is running a loop while the loop is executing and you will see the result immediately in the next iteration after the change. As mentioned the closest thing with modern languages is JS in Chrome.
- jstx1 4y agoWhen is it useful to have a loop that executes partially with some code and the rest of the way with different code?
- kgwgk 4y agoIt's useful if you have some loop running and you want to stop it for some reason in an orderly fashion. Say you were processing several years of data but now want to stop when the first year is completed for some reason. Maybe it's taking too long and you'll rather keep working with partial results or whatever. You can easily recompile the processing function to raise an error when it reaches the stopping point. Or maybe you noticed that the loop will eventually hit an edge case which is not properly handled currently in the code. You can fix it while the loop gets there. And of course for GUI programming. You can redefine interface behaviours on the fly.
- phoe-krk 4y agoFirst example that comes to my mind: you have a game loop running and you would like to change the way the scene is rendered without restarting the game loop altogether and/or losing the current state of the game.
- mikelevins 4y agoYep, this is definitely useful. I've done this kind of work. It's much faster to build an interactive world if you can tweak everything about it while it runs and see the results instantly. The same goes for some simulations I've worked on (and am working on). It's much faster and easier to get good results if you can see the effects of your changes in real time, as the simulation runs.
- deleted 4y ago[deleted]