CHAPTER 13
INTRODUCTION
·
Many programming languages are designed and
implemented in such a way that the user program can neither detect nor attempt
to deal certain run time error conditions.
BASIC CONCEPTS
·
An exception can
be defined as any unusual event, erroneous or not, that is detectable by hardware
or software and that may require special processing.
·
This special processing is called exception handing and is done by a code unit called an exception handler.
·
A language that supports exception handling
encourages its users to consider all events possible during program execution
and how they can be handled.
·
After an exception handler executes, either control
transfers to somewhere in program outside of the handler code, or program execution
simply terminates.
·
Exception handling can be found in PL/I, C++, Ada,
and Java.
EXECPTION HANDLING IN PL/I
·
The concept of exception handling was pioneered in
PL/I.
·
It allows the user to write exception handlers not
only for language-defined exceptions but also for user-defined exceptions.
·
The binding of exceptions to handlers is dynamic.
EXECPTION HANDLING IN ADA
·
Exception handling in Ada is a powerful tool for constructing
more reliable software systems.
·
Exceptions in Ada are statically bound to the
handler when a block or unit that raises an exception includes a handler for it.
·
Ada includes five built in exceptions, however,
user-defined exceptions may also be declared.
·
Exception handling in Ada is a significant advance
over PL/I.
·
Ada was the only widely used language that includes exception
handling until the introduction of C++ and Java.
EXECPTION HANDLING IN C++
·
The design of exception handling in C++ is based in
part on that of CLU, Ada, and ML.
·
There are only user-defined exceptions and there are
not any default handlers
·
The binding of exceptions to handlers is static.
EXECPTION HANDLING IN JAVA
·
Java’s exception handling is based on that of C++.
·
Java supports both system-defined and user-defined exceptions.