The point of having continuations is the ability to use a direct style of coding, even if normally I would be forced to code in a harder-to-use way (for example in an event-driven style).
So the client code I'd wish to be able to write would be like that:
reset {
val event1 = widget1.waitForEvent()
handle1(event1)
val event2 = widget2.waitForEvent()
handle2(event2)
val event3 = widget3.waitForEvent()
handle3(event3)
}
So listener stuff would be hidden from me. But of course, the listeners would still have to be somewhere underneath. I'd hide them in the widget's waitForEvent() method (either added to the Widget class or available through an implicit conversion). The method would look like:
def waitForEvent() = shift { k =>
this.addListener(event => k(event))
k
}
This is at least at the conceptual level. To get this to work you'd need to add some type- and/or @cps annotations probably.