1 ! Copyright (C) 2005 Chris Double, 2007 Clemens Hofreither.
2 USING: help.markup help.syntax coroutines ;
5 { $values { "quot" "a quotation with stack effect ( value -- )" } { "co" "a coroutine" } }
6 { $description "Create a new coroutine which will execute the quotation when resumed. The quotation will have an initial value (received from " { $link coresume } ") on the stack when first resumed.\n\nCoroutines should never terminate normally by \"falling off\" the end of the quotation; instead, they should call " { $link coterminate } "." }
10 { $values { "v" "an object" } { "co" "a coroutine" } { "result" "an object" } }
11 { $description "Resume a coroutine with v as the first item on the stack. The result placed on the stack is the value of the topmost argument on the stack when " { $link coyield } " is called within the coroutine." }
12 { $see-also *coresume coresume* }
16 { $values { "co" "a coroutine" } { "result" "an object" } }
17 { $description "Variant of " { $link coresume } " that passes a default value of " { $link f } " to the coroutine." }
18 { $see-also coresume coresume* }
22 { $values { "v" "an object" } { "co" "a coroutine" } }
23 { $description "Variant of " { $link coresume } " that discards the result of the coroutine invocation." }
24 { $see-also coresume *coresume }
28 { $values { "v" "an object" } { "result" "an object" } }
29 { $description "Suspend the current coroutine, leaving the value v on the stack when control is passed to the " { $link coresume } " caller. When this coroutine is later resumed, result will contain the value passed to " { $link coyield } "." }
30 { $see-also *coyield coyield* coterminate }
34 { $values { "v" "an object" } }
35 { $description "Variant of " { $link coyield } " that returns a default value of " { $link f } " to the caller." }
36 { $see-also coyield coyield* }
40 { $values { "v" "an object" } }
41 { $description "Variant of " { $link coyield } " that discards the value passed in via " { $link coresume } "." }
42 { $see-also coyield *coyield }
46 { $values { "v" "an object" } }
47 { $description "Terminate the current coroutine, leaving the value v on the stack when control is passed to the " { $link coresume } " caller. Resuming a terminated coroutine is a no-op." }
52 { $description "Variable which contains the currently executing coroutine, or " { $link f } " if none is executing. User code should treat this variable as read-only." }
53 { $see-also cocreate coresume coyield }