a) Write down what will be the output of the following program and briefly justify your answer. b) Instead of the “replacement” semantics of exception handling used in modern languages (i.e., the semantics introduced in lecture), a very early design of exception handling introduced in the PL/I language uses a “binding” semantics. In particular, the design dynamically tracks a sequence of “catch” blocks that are currently active; a catch block is active whenever the corre- sponding try block is active. Moreover, whenever an exception is thrown, the sequence of active “catch” blocks will be traversed (in a first-in-last-out manner) to find a matching handler. Fur- thermore, execution will resume at the statement following the one that throws exception, rather than the next statement after the matching “catch” block as we have seen in the “replacement” semantics. What will be the output of the following program if the language uses the “binding” semantics? Briefly justify your answer
a) Write down what will be the output of the following
answer.
b) Instead of the “replacement” semantics of exception handling used in modern languages
(i.e., the semantics introduced in lecture), a very early design of exception handling introduced
in the PL/I language uses a “binding” semantics. In particular, the design dynamically tracks a
sequence of “catch” blocks that are currently active; a catch block is active whenever the corre-
sponding try block is active. Moreover, whenever an exception is thrown, the sequence of active
“catch” blocks will be traversed (in a first-in-last-out manner) to find a matching handler. Fur-
thermore, execution will resume at the statement following the one that throws exception, rather
than the next statement after the matching “catch” block as we have seen in the “replacement”
semantics. What will be the output of the following program if the language uses the “binding” semantics?
Briefly justify your answer
Trending now
This is a popular solution!
Step by step
Solved in 3 steps