4 ms·
I always expect them to use (thread-) global state, not unlike good old errno just more structured. There's always at most one bubbling up so that's how I would
by loa_in_ 5y ago
I always expect them to use (thread-) global state, not unlike good old errno just more structured. There's always at most one bubbling up so that's how I would do it.
- marcosdumay 5y agoBut then you'll have a branch on every failable operation and slow down the happy path. This is not too different from passing the error as a value. Instead, compilers use long jumps and manually edit the stack. I'm not sure it makes a lot of difference today, but branches were really problematic by the time the OOP languages were popularizing.
- astrange 5y agoThey're not bad these days if they're predictable. There's a code size cost, but there's also a cost to emitting all the cleanups and exception safety too. For instance Swift doesn't have exceptions - it has try/catch but they simply return, though with a special ABI for error passing.
- wruza 5y agoI believe that today a cold branch is just gets predicted as not taken and stays as such because it never jumps (in terms of a predictor’s statistics, not literally).