Previous: , Up: srfi receive   [Index]


2.5.4 Specification

Syntax: receive formals expression body

formals, expression, and body are as described in R5RS. Specifically, formals can have any of three forms:

(variable1 ... variablen)

The environment in which the receive–expression is evaluated is extended by binding variable1, ..., variablen to fresh locations. The expression is evaluated, and its values are stored into those locations (it is an error if expression does not have exactly n values).

variable

The environment in which the receive–expression is evaluated is extended by binding variable to a fresh location. The expression is evaluated, its values are converted into a newly allocated list, and the list is stored in the location bound to variable.

(variable1 ... variablen . variablen+1)

The environment in which the receive–expression is evaluated is extended by binding variable1, ..., variablen+1 to fresh locations. The expression is evaluated. Its first n values are stored into the locations bound to variable1, ..., variablen. Any remaining values are converted into a newly allocated list, which is stored into the location bound to variablen+1 (it is an error if expression does not have at least n values.

In any case, the expressions in body are evaluated sequentially in the extended environment. The results of the last expression in the body are the values of the receive–expression.