3 ms·
It's still evil - what if the input program doesn't halt, or allocates too much memory?
by Ao7bei3s 10y ago
It's still evil - what if the input program doesn't halt, or allocates too much memory?
- shakna 10y agoYou design the functional building blocks. So a non-halting program would likely use a single stack, and never grow. But more than that, you can use continuations to abort the moment the calculation is too large.
- codemac 10y agoAny examples of using continuations to abort when the calculation is too large? Still grappling with continuations, familiar with coroutines/csp/fibers much more for concurrency, but trying to get call/cc fully under the belt.
- shakna 10y agoI'd probably nest a named let inside a continuation. Raise an exception when an iterator goes too long. Something like that. I tend to avoid continuations in production code, because how it reacts very much depends on what you're accomplishing. Most exception handling frameworks use continuations, which you can accidentally turn into infinite loops if you don't abort the loop properly.