Sather Home Page

Section 6.3.2:
Iter Signatures

An iterator (or 'iter' for short) is a language construct that encapsulates programmer-defined looping control structures in a similar manner to the role played by routines in the specification of algorithms. An iter signature therefore defines the forms and types of arguments and, if appropriate, a yielded value type definition.

The only difference between routine and iter parameters is that an iter parameter may be specified as once, in which case it is only evaluated on initial entry to the iterator. The only visible difference to the programmer in distinguishing between a routine and an iter is that the iter identifier is followed by an Iter_Signifier_SY ('!') to form an iter name.

Concrete Syntax

abstract iter signature = iter name, [iter parameter pack], [return signature] ;
iter parameter pack = Left_Parenthesis_SY,
iter argument list, Right_Parenthesis_SY ;
iter argument list = iter argument, {Comma_Sy, iter argument} ;
iter argument = iter mode, identifier list, return signature ;
iter mode = [(Out_SY | Inout_SY | Once_SY)] ;

Abstract Syntax

The Feature abstract syntax which is common to all class components is given here with an invariant specifically for the case of an iterator. Since this is a signature there is no implementation component and no value.

Feature ::
name : token
args : [ set of Feature ]
kind : [ Type_Specifier ]
value : [ Expression ]
impl : [ seq of Statement ]
vis : [ Visibility ]
ext_vis : Visibility
uses : [ Method_Kind ] ;

inv mk_Feature(-,-,-,val,impl,-,-,use) ==
use = Multiple
and impl = nil
and val = nil

Static Semantics

TO BE DONE

Dynamic Semantics

Having no implementation and no value - being only a signature (found in abstract classes or as a stub or type definition), there can be no run-time meaning.


Specification Index Language Index Examples Section 6 Index
Comments or enquiries should be made to Keith Hopper.
Page last modified: Wednesday, 25 October 2000.
Produced with Amaya