Concepts of Programming Languages

(Sean Pound) #1

668 Chapter 14 Exception Handling and Event Handling


catch(float) {... }

...
}
}
class Small {
int j;
float g;
void fun2() throw float {
...
try {
...
try {
Big.fun1();
...
throw j;
...
throw g;
...
}
catch(int) {... }
...
}
catch(float) {... }
}
}


In each of the four throw statements, where is the exception handled?
Note that fun1 is called from fun2 in class Small.


  1. Write a detailed comparison of the exception-handling capabilities of
    C++ and those of Java.

  2. With the help of a book on ML, write a detailed comparison of the
    exception-handling capabilities of ML and those of Java.

  3. Summarize the arguments in favor of the termination and resumption
    models of continuation.


PROGRAMMING EXERCISES



  1. Write an Ada code segment that retries a call to a procedure, Tape_Read,
    that reads input from a tape drive and can raise the Tape_Read_Error
    exception.

  2. Suppose you are writing a C++ function that has three alternative
    approaches for accomplishing its requirements. Write a skeletal version
    of this function so that if the first alternative raises any exception, the

Free download pdf