Assignment 11: Adding exceptions
1 Problem description
2 Submission
7.2

Assignment 11: Adding exceptions

Due: Fri 04/05 at 8:59pm

1 Problem description

  1. How could we add exceptions and try-catch expressions to Garter? Consider how to "unwind" from the stack frame that throws a value back to whichever stack frame tries to catch it. Consider how to support compositional try-catch blocks (i.e.,

    try { try { ... } catch ... { ... } } catch ... { ... }
    try { ... } catch ... { try { ... } catch ... { ... } }
    try { ... } catch ... { ... } ; try { ... } catch ... { ... }

    and other nestings) — note that try-catch can appear in expression positions, and design a semantics for them. Consider what types of values can be thrown and caught by your language. Consider what the return value of these expressions should be. Consider how it impacts static typing...

    Do not overly concern yourself with efficiency on this problem; I’m more interested in what expressiveness you can obtain.

    Assume that we take for granted any lexing and parsing changes needed for this new language feature; you do not need to explain them.

  2. What would it take to add a finally { ... } block to these, which runs regardless of whether the try or the catch block ultimately complete?

2 Submission

Wait! Please read the assignment again and verify that you have not forgotten anything!

Please submit your homework to https://handins.ccs.neu.edu/ by the above deadline.