2 ms·
The difference between those 3 examples is that the first two lean on the compiler for some nice rewards and the last one on the developer remembering to check
by alkonaut 4y ago
The difference between those 3 examples is that the first two lean on the compiler for some nice rewards and the last one on the developer remembering to check the err variable.
Syntax wise it’s not much worse (until you start having multiple possible errors in a sequence when its ugliness scales linearly), but the problem is that you pay the 4-5 lines of boilerplate for zero rewarded guarantees such as “if the first thing failed the second can’t/won’t be attempted”. It feels like a lot of syntax cost and boilerplate boredom without much reward.