next up previous
Next: Example Up: The Basic Structure of Previous: The Basic Structure of

The Use Modes of ``asm''-Constructs

As mentioned above, an XASM formalization is structured using ``asm...endasm'' units. In order to explain the relationships that can exist between these units, we will first introduce the possible ``use modes'': An asm can be accessed by other asms in either of the following two ways:

The first way, called subasm-call is visualized in Figure 3. If an asm A uses B as sub-asm, it means that B - possibly together with arguments, if the arity of B>0 - is used as a rule in the body of A. If this rule fires, the rules of asm B fire, which may result in updating locations of functions declared in A. The sub-asm-use relation between asms may contain cycles; lazy evaluation techniques are used to avoid an infinite number of rules. The call as subasm is illustrated in the figure. The sub-asm B and its parent asm A step simultaneously; formally they can be seen as one single ASM.

Figure 3: Call as subasm
\begin{figure}\begin{center}
\epsfxsize 8cm
\hspace*{0cm}\epsfbox{subasm-call.eps} \end{center} \end{figure}

The second way, called function call is visualized in Figure 4. Asm A uses B as a function, if B is defined as in A. In this case, B - possibly together with arguments, if the arity of B>0 - is used as a term in the body of A. Recursion is allowed, so that the function-use relation between asms may contain cycles. The call as function is illustrated in the figure. During the run of the function-asm B, its parent A doesn't make any step; from A's point of view B's run happens in zero time. As depicted in the figure, B behaves like a ``normal'' asm, the iterations shown here are caused by the steps of the B-asm itself.

Figure 4: Call as function
\begin{figure}\begin{center}
\epsfxsize 8cm
\hspace*{0cm}\epsfbox{function-call.eps} \end{center} \end{figure}

In each of the above cases, we call A the parent-asm of B, if A uses B as sub-asm or as function. In any case, the asm must be declared in the parent asm. As part of its meta information, an asm can be marked as a function or as a sub-asm, so that it can only be used by other asms in the specified way. For example, if B and C are asms defined as follows


\begin{asmfbox}
\ASM B(x:Int) \rightarrow Int
\USEDAS \FUNCTION
\IS
\ldots
\ENDASM
\end{asmfbox}

\begin{asmfbox}
\ASM C(x:Int)
\USEDAS \SUBASM
\IS
\ldots
\ENDASM
\end{asmfbox}


then B can only be used as function and C as sub-asm in other asms. This is reflected by corresponding declarations of B and C:


\begin{asmfbox}
\ASM A
\IS
\SUBASM C(x:Int)
\EXTERNAL \FUNCTION B(x:Int) \rightarrow Int
\ldots
\ENDASM
\end{asmfbox}



next up previous
Next: Example Up: The Basic Structure of Previous: The Basic Structure of
Philipp Kutter 2002-03-18