W Wrapl, The Programming Language

Libraries Sys.Coexpr

Types

T

A coexpression type for cooperative multitasking or complex program flow control.

Whenever a coexpression switches control to a paused coexpression, it passes a transfer value to the activated expression. The method/function which paused the coexpression will return the transfer value when the coexpression is reactivated.

Coexpressions are protected by mutexes; attempting to activate a running coexpression from a second thread will cause the second thread to block until the coexpression is paused in the first thread.

Functions

Caller() : T

Returns the coexpression that activated the current coexpression. If the current coexpression is the initial coexpression in a thread, then returns Self().

New(func @ Std.Function.T, size @ Std.Integer.SmallT = 16352)

Returns a new coexpression with entry point func and a stack of size size bytes.

Self() : T

Returns the current coexpression.

Switch(coexpr @ T, value)

Transfers control to coexpr with value as the transfer value. When control passes back to this coexpression, returns the transfer from the activating coexpression.

Yield(value)

Transfers control to the coexpression that activated this one, with value as the transfer value. When control passes back to this coexpression, returns the transfer from the activating coexpression.

Methods

:"^"(value @ T)

Transfers control to coexpr with NIL as the transfer value. When control passes back to this coexpression, returns the transfer from the activating coexpression.

:"^"(value, coexpr @ T)

Transfers control to coexpr with value as the transfer value. When control passes back to this coexpression, returns the transfer from the activating coexpression.

:collect(co @ T) : Agg.List.T

Returns the values produced by co as a list.