~ chicken-core (master) /manual/Module (chicken continuation)
Trap1[[tags: manual]]2[[toc:]]34== Module (chicken continuation)56This module provides a more powerful interface for continuations than that7provided by {{call/cc}}.89More information about this continuation API can be found in the paper10[[http://www.iro.umontreal.ca/~feeley/papers/FeeleySW01.pdf|A Better11API for First-Class Continuations]] by Marc Feeley.1213=== Continuations API1415==== continuation-capture1617<procedure>(continuation-capture PROCEDURE)</procedure>1819Creates a continuation object representing the current continuation and20tail-calls {{PROCEDURE}} with this continuation as the single argument.212223==== continuation?2425<procedure>(continuation? X)</procedure>2627Returns {{#t}} if {{X}} is a continuation object, or {{#f}} otherwise. Please28note that this applies only to continuations created by the Continuation API,29but not by call/cc, i.e.: {{(call-with-current-continuation continuation?)}}30returns {{#f}}, whereas {{(continuation-capture continuation?)}} returns31{{#t}}.323334==== continuation-graft3536<procedure>(continuation-graft CONT THUNK)</procedure>3738Calls the procedure {{THUNK}} with no arguments and the implicit continuation39{{CONT}}.404142==== continuation-return4344<procedure>(continuation-return CONT VALUE ...)</procedure>4546Returns the value(s) to the continuation {{CONT}}. {{continuation-return}} could47be implemented like this:4849<enscript highlight=scheme>50(define (continuation-return k . vals)51 (continuation-graft52 k53 (lambda () (apply values vals))))54</enscript>555657----58Previous: [[Module (chicken condition)]]5960Next: [[Module (chicken csi)]]