Comment

Comment by SlowRobotAhead

> It’s like a goto statement, but it can even be used to jump outside of a function. It’s also a lot more difficult to read than a goto, since it looks like a regular function call.

Ah! Blood pressure rising!

> Like with goto, the common advice is to avoid

Whew. And then goes on to make a really good case for complicated task perform with simple error handling.

It’s a good application for not exactly general use cooperative routines but a specific use case of performing multiple procedural steps.

I think there it falls short and where an RTOS/OS will be more useful is when you have to wait on one of those steps.

I think that’s the harder example with the example of an HTTP request is waiting for the response and keeping that context ready and blocking in a separate thread. That ends up being easy to read and maintainable. But I suppose there is no reason you can’t do both.

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton