Flow of Data and Control
This part of Kernel AN2 is a combination of the Basic and Functional facets of AN1. Notice that there are no yielders: the efect of yielder evaluation in AN1 is achieved in Kernel AN2 by combinations of 'provide d' and 'give o', using 'and' and 'then'. For expressing normal and exceptional dataflow, AN2 provides the same combinators as AN1 only renaming regive to copy, escape to raise, and trap to exceptionally. It also provides the exceptional counterpart of and then, written A1 and exceptionally A2, where A2 is performed, with the same data as A1, only if A1 terminates exceptionally, and the data given by A1 and A2 are concatenated only if A2 also terminates exceptionally. For example, when A terminates exceptionally with data d, A and exceptionally raise terminates exceptionally with d appended to the data given to A. The treatment of failure and alternative actions in AN-2 is different from that in AN-1. When there are storing and communicating actions , they do not discard alternative actions and if a failure occurs in a selected action, an alternative action simply continues with the current information, which may well di#er from that at the beginning of the firstperformed alternative. However, selecting to perform an 'infallible' action (i.e., one that cannot fail) corresponds to an implicit commitment, since any alternatives to it can never be performed. AN2 includes a new combinator, A1 otherwise A2, where A2 is an alternative action to A 1, but not vice versa: A 2 gets performed only if A 1 fails. Symmetric choice between alternatives A1 or A2 is still available; however, all the alternatives of a particular selection now have to be enclosed in select (. . .). Thus select(A 1 or . . . or A n ) performs any of the A i first; on failure of the selected A i , it performs the choice between the remaining A j with the same data. The only primitive action in AN2 that can fail is the fail action itself. All other primitive actions that cannot terminate normally are supposed to terminate exceptionally, with no data, rather than failing. Then, Failure is reserved to control choice between alternative actions. Note that check p terminates exceptionally unless p holds, rather than failing, so it cannot be used directly as the guard of an alternative; however, Full AN2 defines the notation when p to abbreviate a corresponding action that fails unless p holds, so when p then A1 otherwise A2 expresses the deterministic selection of A1 or A2, depending on whether p holds or not. In AN1, choose could be used to select individual values from arbitrary sorts, including cells, agents, and actions. Thus there was no guarantee that a freshlyallocated cell or contracted agent was previously unknown, nor that knowledge of its identity could be kept local. In AN2, choose cannot be used for cells, agents, or actions. For simplicity (and to avoid the need for data sorts as arguments of actions) the only sort from which one may select values arbitrarily is Natural, the sort of natural numbers. Note that unfolding A and unfold are no longer kernel actions in AN2, but are regarded as abbreviations and defined in Full AN2. Essentially, unfolding A corresponds to the declaration and immediate call of a recursive parameterless procedure with body A, and unfold to its recursive call, which can be expressed straightforwardly using Kernel AN2 actions for binding and enaction. |
Data| Flow of Data and Control| Scopes of Bindings| Interactive Processes