IncrementalReceive[default]
pauses the enclosing incremental function and on resumption returns the value from "Send" or default.
IncrementalReceive
IncrementalReceive[default]
pauses the enclosing incremental function and on resumption returns the value from "Send" or default.
Details
- IncrementalYield can only be used in Function expressions marked with IncrementalFunction.
- Functions in which IncrementalReceive appears have to be processed by compiler functions such as FunctionCompile.
- After executing IncrementalReceive, the incremental function will save its local variables and return to the caller.
- When an incremental function paused by a call to IncrementalReceive is resumed with a call to "Send", the result of the execution is the value.
- When an incremental function paused by a call to IncrementalReceive is resumed with a call to "Next", the result of the execution is the default value.
- When an incremental function is created, it pauses before any code is executed and has to be started with a call to "Next".
Examples
open all close allBasic Examples (2)
An incremental function that has one receive:
comp = FunctionCompile@IncrementalFunction@Function[{}, Echo[IncrementalReceive[0]];];Create an instance of the incremental function:
ds = comp[]Run the incremental function until it reaches the first IncrementalReceive:
ds["Next"]A value can be sent to the incremental function with "Send":
ds["Send", 101]The incremental function has finished, so nothing more can be sent to it:
ds["Send", 22]An incremental function that can work to output a message:
comp =
FunctionCompile@IncrementalFunction@Function[{},
While[
True,
Echo[ IncrementalReceive[InertExpression["Nothing Came"]]]
]
];Create an instance of the function and run it until it reaches the first IncrementalReceive:
fun = comp[];
fun["Next"]Send an expression to the function, and it gets printed:
fun["Send", x]fun["Send", "string"]Compound expressions can be sent:
fun["Send", f[1, x]]If "Next" is called, then the default value of the IncrementalReceive is returned:
fun["Next"]Scope (1)
This incremental function prints a string before it reaches IncrementalReceive:
comp = FunctionCompile@IncrementalFunction@Function[{}, Print["started"];Echo[IncrementalReceive[0]];];This creates an instance of the incremental function; the function is paused before any code has been executed:
ds = comp[]The incremental function starts to run when "Next" is called; it will pause when it reaches IncrementalReceive:
ds["Next"]When a value is sent to the incremental function with "Send", this causes it to resume:
ds["Send", 101]See Also
IncrementalFunction Function Typed FunctionCompile FunctionDeclaration IncrementalYield
Compiled Types: IncrementalFunction
Tech Notes
Related Guides
History
Text
Wolfram Research (2025), IncrementalReceive, Wolfram Language function, https://reference.wolfram.com/language/ref/IncrementalReceive.html.
CMS
Wolfram Language. 2025. "IncrementalReceive." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/IncrementalReceive.html.
APA
Wolfram Language. (2025). IncrementalReceive. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/IncrementalReceive.html
BibTeX
@misc{reference.wolfram_2026_incrementalreceive, author="Wolfram Research", title="{IncrementalReceive}", year="2025", howpublished="\url{https://reference.wolfram.com/language/ref/IncrementalReceive.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_incrementalreceive, organization={Wolfram Research}, title={IncrementalReceive}, year={2025}, url={https://reference.wolfram.com/language/ref/IncrementalReceive.html}, note=[Accessed: 13-June-2026]}