2 ms·
You can still get something like that using exceptions, it depends on where the exceptions are caught. If you have a function which has 3 calls: function f (
by Jtsummers 8y ago
You can still get something like that using exceptions, it depends on where the exceptions are caught. If you have a function which has 3 calls:
function f (...) {
val a = something.a();
val b = something.b();
val c = something.c();
return (a,b,c);
}
If the exceptions can occur in the calls assigning to a, b, or c and are handled locally (here, in f) then you can construct that first case. It's only if you throw the exception up one level higher that you end up in the latter case. As written, it is more like your latter example. But with a modication:
function f(...) {
val a = default_a;
val b = default_b;
val c = default_c;
try {
a = something.a();
} catch {
a = error_value_a;
}
...
}
You can get the former case.