
%\documentstyle{csart}

%\begin{document}

\section{\label{where}Where Usage}

     The \verb$WHERE$ construct can be regarded as a form of parellel loop.
As in {\em occam}, parallel constructs need some usage rules associated
with them.  We have not discussed the possibility of channel communication
inside \verb$WHERE$ constructs, so for the purposes of this document
we don't need a usage rule for channels.  This leaves treatment of
variables.  Fairly clearly, the variable usage rules only need
restrict use of ``global'' variables---that is to say, inside a
\verb$WHERE {x}$ construct, we only need to put restrictions on
variables {\em not} distributed over $x$.  There is no danger
of parallel access to variables which {\em are} $x$ distributions.

     There are two plausible choices of usage restriction on global
variables.  The most ``natural'' is to treat \verb$WHERE$ as if it
were a \verb$PAR$, the restriction being that only one component of the
loop may write to a particular global variable, and if any component does
so, no component may read that variable.  An advantage of this scheme
is that it provides an intrinsic mechanism for copying an element
of a distribution to a global variable.  For example
\begin{linear}
\begin{verbatim}

    {x} INT A :
    INT b :

    WHERE {x}
      IF
        x = 23
          b := A
        TRUE
          SKIP

\end{verbatim}
\end{linear}
copies the 23rd element of $A$ to $b$.

     One disadvantage of this regime is that in the static
implementation the assignment \verb$b = A$ has to be implemented
implicitly as a broadcast.
This implementation is difficult,
because the sites (if any) from which broadcasts are
to proceed are not known globally. 

     Such considerations suggest a second regime in which assignments
to global variables are simply forbidden inside \verb$WHERE$ constructs.
Any broadcasts require explicit calls to a communication routine.
(Incidentally, a minor advantage of this more restrictive scheme is that
usage-checking is now ``automatic''---essentially no more difficult than
type-checking.)

     At a purist level the choice between the two regimes 
would presumably favour the former---the advantage is
in having the possibility of broadcasts instrinsic to the language,
especially since any communication pattern then {\em can}
be built (probably very inefficiently) from broadcasts,
without recourse to externally defined communication procedures.
From an implementation point of view the second regime is
more attractive.

%\end{document}
