Yield Statement



next up previous contents index
Next: Signal Statement Up: Statements Previous: Return Statement

Yield Statement

A yield statement may occur only in the body of an iterator (6). Its form is
yield "(" <expr> ["," <expr>]* ")"
It has the effect of suspending operation of the iterator and returning control to the invoking for statement (8.8). There must be the same number of expressions as there are yield types listed in the iterator's header, and their types must be subtypes of the corresponding listed types. The values obtained by evaluating the expressions (in an unspecified order) are passed to the for statement to be assigned to the corresponding loop identifiers. After the body of the for loop has been executed, execution of the iterator is resumed at the statement following the yield statement.



theta-questions@lcs.mit.edu