Checked vs unchecked exceptions

Tobias Müller via Digitalmars-d digitalmars-d at puremagic.com
Mon Jun 26 23:10:52 PDT 2017


Moritz Maxeiner <moritz at ucworks.org> wrote:
> [...]
> Or, more succinct: You must either manually write things down the 
> compiler could find out in a fraction of the time via static 
> analysis, or cheat the system; both cases are bad code.

It's not at all bad code to write things down that the compiler could
infer, quite the opposite.
Writing it down signals _intent_ and the compiler can check if the
implementation is matching the specification which gives you additional
security.
Additionally it allowes the compiler to do the checks locally which is much
easier.

Function signatures are interfaces which should be self-contained IMO, i.e.
it should not be necessary to examine the function body. That's what
signatures are for. At very least for public interfaces.

I honestly don't understand how people that care a great deal about
expressive type systems can be so opposed to checked exceptions. After all
they wouldn't use 'object' for everything either.

Tobi



More information about the Digitalmars-d mailing list