4 ms·
The main difficulty is that, very often, I do want my programs to loop forever/indefinitely. (Or at least until someone shuts them down).
by ktRolster 10y ago
The main difficulty is that, very often, I do want my programs to loop forever/indefinitely. (Or at least until someone shuts them down).
- wyager 10y agoRight! That's the point of codata. If you want your program to run forever, you could express e.g. I/O events as an infinite (codata) stream. Then, instead of trying to prove that your program terminates (which it might not), it proves that your program "does something useful" every time it gets an IO event, for a particular practical definition of "doing something useful".
- SomeStupidPoint 10y agoWould it significantly harm your experience if all your programs turned off after 1000 years of execution without input? If not, your program could be "total" in most of the useful senses, and subparts could have tighter bounds, without any harm.
- skybrian 10y agoSure, for the main loop. But you probably don't want any function called from the main loop to run forever. (In JavaScript, any single event handler should terminate quickly or it becomes unresponsive.)