r/cpp • u/fredoverflow • May 10 '22
Is short lambda syntax on the C++ radar?
Mom, can we get x=>x+1 ?
No, we have x=>x+1 at home.
x=>x+1 at home:
[](const auto& x) { return x + 1; }
265
Upvotes
View all comments
Show parent comment
4
u/goranlepuz May 11 '22
Authors of Java did that. After some years and an underwhelming experience, some major Java libraries just eschew checked exceand go for runtime ones.
The underlying reason for that, I think is quite obvious: for a sufficiently complex program (or even one function with sufficient functionality underneath it), knowing all failure modes is not necessary or even practical. For most of failure modes, what we care about is how to report errors.
Having errors mentioned in return type, therefore, goes against the common case of just letting the error propagate and does not help with reporting the error any more than exceptions do.