Hacker News new | ask | show | jobs
by shakna 3526 days ago
You 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.
1 comments

Any 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.
I'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.