01: package kawa.lang;
02:
03: import gnu.mapping.*;
04:
05: /**
06: * A Continuation "represents an entire (default) future for the computation.
07: * This implemementation is based on Java exceptions, and is restricted
08: * to "upward" (?) continuation (i.e. catch/throw-type uses).
09: * @author Per Bothner
10: */
11:
12: public class Continuation extends MethodProc {
13: public boolean invoked;
14: static int counter;
15: int id;
16:
17: public Continuation(CallContext ctx) {
18: }
19:
20: public void apply(CallContext ctx) {
21: if (invoked)
22: throw new GenericError(
23: "implementation restriction: continuation can only be used once");
24: throw new CalledContinuation(ctx.values, this );
25: }
26:
27: public final String toString() {
28: return "#<continuation " + id + (invoked ? " (invoked)>" : ">");
29: }
30: }
|