next up previous contents
Next: Expressions Up: Method Calls Previous: Procedure Calls

Stream Objects, Stream Calls and the Resume Statement

  A stream call is used for successively accessing the elements of data structures. This is achieved either by a direct stream call or by establishing an explicit stream object which then may be called.

A direct call of a stream method or the call of a stream object has the form tex2html_wrap_inline2453 where a is the name of the stream or the stream object.

A direct stream call is executed in the same way as a procedure call. But if during the execution of the body of the stream method a statement resume is met then the execution of the call is suspended, and the result, if any, and all out- and inout-parameters are returned to the caller (steps 7, 8 of 6.7.1).

Direct stream calls must be syntactically contained within a loop. On suspension of the stream call the execution of the loop is continued. Whenever the loop body is repeated then the same direct call is executed by continuing the stream method after the resume statement. At this time the in- and inout-arguments of the call are reevaluated and reassigned to the corresponding parameters.

The execution of a direct call terminates when a return statement or the end of the body of the stream method is reached. Termination of a direct stream call also terminates the execution of its innermost enclosing loop. At this time the result and the values of out- and inout-parameters, if any, are not transmitted to the caller; the class invariant is checked.

Note: There might be several stream calls within a loop; the first terminating one terminates the loop. All direct calls at syntactically different positions are different, even when they use the same stream method. tex2html_wrap_inline1707

Direct calls implicitly establish a stream object whose state between calls indicates how far the stream has progressed. An explicit stream object may be established by assigning a bound stream to a local quantity of the appropriate stream type. Establishing a stream object requires that all arguments corresponding to once parameters are given; arguments for out- and inout-parameters cannot be given. Then a bound method with the remaining free parameters together with the (uninitialized) stream state is created.

The stream object may be used instead of a stream method within a stream call with the same meaning as a direct call; especially, when such a call terminates within a loop then the loop is terminated. Additionally, such calls may also occur outside of loops and they always designate the same stream. If a call terminates outside of a loop or if an already terminated stream object is called then the exception STREAM_TERMINATION is raised.

Every explicit stream object has the automatically declared Boolean attribute terminated which has the value true after termination and false before.

For predefined stream methods see 8.1.


next up previous contents
Next: Expressions Up: Method Calls Previous: Procedure Calls

Martin Trapp
Mon Feb 17 16:49:16 MET 1997