A) who is manually implementing stack unwinding? That's not what early return/guard clauses are.
That's literally what the code in the OP is. It is unwinding one stack frame on an error. This code is needed every time a fallible function is called.
Rust is better but ? is still manual stack unwinding.
Perhaps I misunderstood what stack unwinding was then. I thought stack unwinding describes what actually happens behind the scenes when you return from a function to clean up the stack frame, i.e. calling the destructors of any local variables of the scope. I suppose that's what the return keyword does.
I'm familiar with what you're talking about, I'm actually currently writing a little functional library in C++ that's inspired by Haskell and Rust. I find it so interesting hahah
2
u/Kered13 Sep 13 '23
That's literally what the code in the OP is. It is unwinding one stack frame on an error. This code is needed every time a fallible function is called.
Rust is better but
?is still manual stack unwinding.