next up previous contents index
Next: Pre-translation Up: Static Semantic Checking Previous: Static Semantic Checking   Contents   Index


Subscripting

In section 5.3 we gave a handful of special rules for distributed array element access. One example is that in

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
\verb$ overal...
...{\tt ]}$ \verb$ ...$ \\
\verb$ }$
\end{tabbing}\end{minipage}\end{displaymath}

the expression $a$ must be invariant in the overall construct.

Proving that an arbitrary expression is invariant throughout a particular block of code can be a very hard problem for a compiler. The block of code (our overall construct) may, for example, contain method invocations. If the expression we are analysing involves fields or array elements, it is not generally possible to be prove that the method invocation does not change the value of the expression as a side-effect. On the other hand, if one failed to prove that expressions like $a$ above were invariant, the loss of efficiency in the translated code might be quite spectacular.

For these reasons the translator imposes the following, fairly sweeping, restrictions [Actually these aren't implemented in the current translator--neither are the run-time checks that should be associated with subscripting multiarrays and distributed arrays.]:

We can now very cleanly enforce the original requirements on subscripting in overall and at constructs, by applying a simple static check that if a distributed index i appears in a subscript of a distributed array a, the variable a should have been declared outside the scope of i, and (if it is a blank final) $a$ should not be assigned inside the scope of i. The Java constraints on assignments to blank final make the latter check easy.


next up previous contents index
Next: Pre-translation Up: Static Semantic Checking Previous: Static Semantic Checking   Contents   Index
Bryan Carpenter 2003-04-15