> Exceptions have very high performance costs (equivalent to a longjmp which is very slow)
Could you elaborate on why they are so slow, compared to passing around/returning error objects explicitly?
Could you elaborate on why they are so slow, compared to passing around/returning error objects explicitly?
In a sense, try/catch would then just be syntactic sugar that frees you from manually checking for errors after every single function call. Instead, you just handle them in bulk in a catch block, potentially a couple stack frames further upstairs.
EDIT: I just realized my suggestion wouldn't exactly be equivalent to exceptions, in the sense that it wouldn't give stack traces but error return traces, like in Zig:
https://ziglang.org/documentation/master/#Error-Return-Trace...
Here someone else had the same idea: https://news.ycombinator.com/item?id=34846550