Hmm. I can't say I'm really a fan of the proposed API for delimited continuations. I'd really like to see something like this (pseudocode):
public DelimitedContinuation makeAdder(final Integer value) { final StackMarker m = new StackMarker(); return (DelimitedContinuation)m.shift(new Callable<Object> { public Object call() { // if reset is called, a return/exception here // propagates to the continuation's caller, or else // to the m.shift() call site if prior to m.reset() return value + (Integer)m.reset( new DelimitedCapture() { public Object call(DelimitedContinuation dc) { // return/exception here unwinds back to // call site of m.shift() return dc; } } }); } }) } ... DelimitedContinuation adder; Integer result; adder = makeAdder(3); result = (Integer)adder.call(4); assert result == 7; result = (Integer)adder.call(6); assert result == 9 One of the *really* important properties of delimited continuations is that they are simple functions: they take an argument, they return a value. Additionally, ideally it should be possible to use 'adder' from many threads at once safely -- that is hard to do if you are forced to use holder objects to get around a lack of arguments or return values. I think in addition to delimited continuations (which need to be multi-shot and threadsafe insofar as they don't mutate shared objects), there is also a need for separate explicit support for coroutines, where the internal continuation is one-shot (as distinct from escape-only), thereby avoiding the security implications of full continuations. (Each coroutine would also need to support its own set of threadlocal values, since threadlocals in Java are heavily used for dynamic scoping, and switching between coroutines introduces a different dynamic scope.) -mental
signature.asc
Description: This is a digitally signed message part
_______________________________________________ mlvm-dev mailing list mlvm-dev@openjdk.java.net http://mail.openjdk.java.net/mailman/listinfo/mlvm-dev