3 ms·
But 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, c
by marcosdumay 5y ago
But 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).