Output clause

The output clause assigns values to attributes in output tuples each time the operator submits data to an output stream.

For example, output Sale: item = Bid.item, id = n; assigns values to the attributes item and id in the output stream Sale. The label, such as Sale, is an output stream name or alias, and opens the scope of that stream similarly to a Pascal with statement. The result is a comma-separated list of assignments to attributes.

Most operators have the auto-assignment flag set in the operator model, meaning any attribute in the output stream that is not assigned by the output clause is implicitly copied from an attribute with the same name and type that is defined on an input stream. To find the matching attribute, the compiler searches all attributes that start with port 0 and proceeds until a match is found or all ports are checked. Certain operators might have different forwarding behavior, which is specified by their operator model. For more information about operator models, see Compile-time APIs.

Some operators, such as the Aggregate operator in the standard toolkit, define custom output functions, such as Sum, that are in scope in their output clause. Such custom output functions can be only used in top-level expressions. For example, sum = Sum(i) is correct but sum = (int32)Sum(i) is an error, because it is nested in a cast expression.

Tip: Avoid calling stateful functions in the output clause, since this clause is a confusing place to inject side effects or non-determinism.