7.3.6 B:   ACI
On this page: Introduction Language Web Extension Stencil Code Submission
7.3.6 B: ACI Introduction Language Web Extension Stencil Code Submission Introduction

In this assignment you will implement the ACI (Automatic Callback Insertion) transformation we have discussed in class. Since this is a program transformation, you will implement it using macros (define-syntax and syntax-rules).

After doing so, you will extend and use it to simulate a multi-tab/window Web interaction, to see the effects we have discussed in class. Language

You will define a macro, aci, that takes an expression and returns the same expression converted to ACI-form.

Your macro should handle the following source forms:
  • primitive values (numbers)

  • variables

  • function application (of one argument)

  • lambda (of one argument)

  • set!

  • begin, with two sub-terms

  • + and ++, both of two arguments

The fall-through case should only handle atomic values: numbers, symbols, strings, and booleans. All other values must raise an error. It’s okay for this to happen at run-time (i.e., it can be in generated code, rather than being signaled—as it ideally should—at macro expansion time). Web Extension

Once you have done this, we will extend it to simulate Web programs. Add the following construct to your aci macro:
  • web-read, which takes a string; it prints the string, then halts the program entirely using error (having, of course, first stashed the continuation)

To simulate the user’s interaction with the Web program, we will have a global association between tab numbers and continuations. Each tab has a continuation associated with it, corresponding to the state of execution in that tab. Users can continue execution in a tab, or can create a new tab:
  • restore, which takes two parameters: a tab number and a value. This restores that tab’s computation with the supplied value.

  • clone, which takes a single number representing which tab to clone. It returns a fresh tab number. This fresh tab has (for now) the same continuation as the tab that was cloned.

Also implement reset-tabs, which (if necessary) resets any temporary variables you set for yourself to keep track of tab numbers and/or restoration points. We will be running it in-between tests so that tabs set in previous tests do not interfere with later tests, i.e., there’s a pristine “browser” environment between tests. Stencil Code Submission