Checked vs unchecked exceptions
jmh530 via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jun 26 09:35:51 PDT 2017
On Monday, 26 June 2017 at 15:15:54 UTC, Steven Schveighoffer
wrote:
>
> No, checked exceptions leads to this (maybe not for you, but
> for 90% of developers out there):
>
> void foo()
> {
> functionWithException();
> }
>
> compiler: foo throws, and you need to handle or declare the
> exceptions it throws
>
> void foo()
> {
> try {
> functionWithException();
> } catch(Exception e) {} // shut up compiler
> }
>
Just curious: how are checked exceptions different from setting
nothrow as the default? Like you would have to write:
void foo() @maythrow
{
functionWithException();
}
So for instance, you could still use your "//shut up compiler"
code with the nothrow default.
More information about the Digitalmars-d
mailing list