Exception Handling IV: try/catch a switch?
David Hough
uunet!Eng.Sun.COM!David.Hough
Tue Oct 8 17:39:45 PDT 1991
try/catch is a sort of like a switch. Maybe if it were more so, the
problems with labels I mentioned previously would go away, e.g. a
somewhat different syntax for the example I have been using:
__eswitch__ (r = d1/d) {
case FE_INVALID: /* invalid division 0/0 or inf/inf detected */
if (d1 == 0) { /* f1 = (0/0)*inf so return infinity */
f1 = q;
} else { /* f1 = (inf/inf)*0 so return "p" */
f1 = (1.0 + f1j2) * b[j + 2] / b[j + 1];
}
break; /* instead of goto... */
default: /* unexceptional case */
f1 = -r * q;
break;
}
Maybe that's an improvement: an __eswitch__ is like a switch, except the
cases are cases of exceptions rather than cases of expression values..
More information about the Numeric-interest
mailing list