"IncrementalFunction" (Compiled Type)
"IncrementalFunction"::[next,send]
represents a type that holds the state of an incremental function that can yield a type next and receive a type send.
Details
- "IncrementalFunction" is used to refer to running instances of functions that have been created with IncrementalFunction.
Constructors
- Instances of "IncrementalFunction" are created by compiling a function that was marked with IncrementalFunction.
Operations
- For an instance of type "IncrementalFunction", the following operations can be used:
-
obj["Close"] terminate execution of the incremental function so that it cannot be resumed obj["Next"] resume the incremental function and let execution continue to the next suspend point or finish obj["Send",val] resume the incremental function sending val and let execution continue to the next suspend point or finish
Properties
- Information[obj,"YieldType"] for obj of type "IncrementalFunction"::[yield,receive] gives "TypeSpecifier"::[yield].
- Information[obj,"ReceiveType"] for obj of type "IncrementalFunction"::[yield,receive] gives "TypeSpecifier"::[receive].
Conversions
- Converting an "IncrementalFunction" object to an expression entails embedding a reference to the incremental function in the expression. This is fast and allows operations to be called. When the expression is freed, the reference to the incremental function is removed, which may cause the function to be permanently terminated and all resources freed.
Expressions
Examples
Basic Examples (1)
Compile a program that returns an incremental function object:
An instance of an incremental function:
Compile a program that takes an incremental function object as argument and calls "Next":
Call "Next" in a compiled function:
Call "Next" from the evaluator:
Calling "Next" again returns a failure, since the incremental function has finished:
Related Guides
Related Links
History
Introduced in 2025 (14.3)