Guides/Continuations

From J Wiki
Jump to: navigation, search

Continuation is a way to capture the execution state in a script, exit the engine while making an external call, then later restore the execution state and resume the script right after the external call, optionally capturing its results.

Continuations are useful for user interface, where the traditional non-linear event-driven or model-view-controller patterns can be replaced with simple control logic (sequence, condition, loop, etc.) This is called inversion of control.

In contemporary context, continuation is interesting for web development. The script is executed at the server and the external routines, which exit the engine, are the web screens, whose alternation represents the user interface.

The continuation pattern is used in process modeling applications such as Service-Oriented Architecture, where process engines are used such as BPEL. There, the exits are web services and the state is captured in a data source.

(How) can it be done in J?

See links below for examples.

WD Wait Example

J SmallTalk
File:Seaside task.ijs.txt File:Seaside task.st.txt

Seaside task.png

See Also

  • WikiPedia:Continuations, Wikipedia
  • Seaside a web framework for SmallTalk featuring continuations
  • Continuity Continuation-Based Web-Programming Library for Perl
  • Borges a continuation-based web framework for Ruby ported from on Seaside 2