Continuations...
I just found a paper, "Trampolined Style", by Gans, Friedman, and Wand, that describes alternatives to continuations.In some respects this style seems even more powerful then CPS with Call/CC. It is related to a technique I used to simulate continuations about 10 years ago using Catch / Throw. It is also distantly related to the technique I now use for running my GigaDSP simulation engines.
In GigaDSP I do not explicitly trampoline anything, but there is an evaluator thread always running against a queue of pending computations for each clock cycle. That queue is actually a 2-level priority queue. The front of the queue contains computations that need immediate processing. The back of the queue contains computations that should run once all pending immediate computations are completed.
The use of a 2-level priority queue (priority based on time of arrival - early arrivals have priority over later arrivals), allows for multi-rate computations and explicit sequencing on sub-clock cycles. Examples of such need would be a Runge-Kutta 4th order Integrator, where each computational time step involves 4 sub-cycles of computations of the corresponding network.
Another example would be where specific blocks of processing must proceed in some defined order. Since the network is asynchronous, one way to achieve an ordering is to produce sub-clock signals, and then tie the ordered block's clock inputs to sequential sub-clock outputs. Subclock initiated computations are added to the back end of the delayed priority portion of the queue. That allows all processing at one subclock interval to proceed to completion before the next subclock cycle gets initiated. And all subclocks proceed to completion before the next major clock cycle of the network.
My experience of a decade ago showed that Common Lisp could successfully use Catch / Throw with a central sequencer loop to simulate call/cc, but the runtime was penalized over kernel provided implementations. Catch / Throw is a relatively heavy-duty operation.
Dr. David McClain
Chief Technical Officer
Refined Audiometrics Laboratory
4391 N. Camino Ferreo
Tucson, AZ 85750
email: dbm@refined-audiometrics.com
phone: 1.520.390.3995