Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

While event #3360

Merged
merged 15 commits into from
May 30, 2023
2 changes: 2 additions & 0 deletions chapters/arrays.tex
Expand Up @@ -580,6 +580,7 @@ \subsubsection{Reduction Expressions}\label{reduction-expressions}
is a \firstuse{reduction expression}.
The expressions in the iterators of a reduction expression shall be vector expressions.
They are evaluated once for each reduction expression, and are evaluated in the scope immediately enclosing the reduction expression.
If \lstinline!expression1! contains event-generating expressions, the expressions inside the iterators shall be evaluable.

For an iterator:
\begin{lstlisting}[language=grammar]
Expand Down Expand Up @@ -753,6 +754,7 @@ \subsection{Constructor with Iterators}\label{array-constructor-with-iterators}\
\end{lstlisting}
is an \firstuse[array!constructor!with iterators]{array constructor with iterators}.
The expressions inside the iterators of an array constructor shall be vector expressions.
If \lstinline!expression! contains event-generating expressions, the expressions inside the iterators shall be evaluable.
They are evaluated once for each array constructor, and are evaluated in the scope immediately enclosing the array constructor.

For an iterator:
Expand Down
2 changes: 1 addition & 1 deletion chapters/equations.tex
Expand Up @@ -104,7 +104,7 @@ \subsubsection{Explicit Iteration Ranges of For-Equations}\label{explicit-iterat

The \lstinline!expression! of a \lstinline!for!-equation shall be a vector expression, where more general array expressions are treated as vector of vectors or vector of matrices.
It is evaluated once for each \lstinline!for!-equation, and is evaluated in the scope immediately enclosing the \lstinline!for!-equation.
The expression of a \lstinline!for!-equation shall be a parameter expression.
The expression of a \lstinline!for!-equation shall be evaluable.
The iteration range of a \lstinline!for!-equation can also be specified as \lstinline!Boolean! or as an enumeration type, see \cref{types-as-iteration-ranges} for more information.
The loop-variable (\lstinline!IDENT!) is in scope inside the loop-construct and shall not be assigned to.
For each element of the evaluated vector expression, in the normal order, the loop-variable gets the value of that element and that is used to evaluate the body of the \lstinline!for!-loop.
Expand Down
12 changes: 11 additions & 1 deletion chapters/statements.tex
Expand Up @@ -177,6 +177,12 @@ \subsection{For-Statement}\label{for-statement}
\end{lstlisting}
The rules for \lstinline!for!-statements are the same as for \lstinline!for!-expressions in \cref{explicit-iteration-ranges-of-for-equations} -- except that the \lstinline!expression! of a \lstinline!for!-statement is not restricted to a parameter-expression.

If the \lstinline!for!-statement contains event-generating expressions, any expression in \lstinline[language=grammar]!for-index! shall be evaluable.

\begin{nonnormative}
In general, the same event-generating expression requires distinct crossing functions for different iterations of the \lstinline!for!-loop, and the restriction ensures that the number of crossing functions is known during translation time.
\end{nonnormative}
HansOlsson marked this conversation as resolved.
Show resolved Hide resolved

\begin{example}
\begin{lstlisting}[language=modelica]
for i in 1 : 10 loop // i takes the values 1, 2, 3, $\ldots$, 10
Expand Down Expand Up @@ -289,7 +295,8 @@ \subsection{While-Statement}\label{while-statement}
end while
\end{lstlisting}
The \lstinline!expression! of a \lstinline!while!-statement shall be a scalar \lstinline!Boolean! expression.
The \lstinline!while!-statement corresponds to while-statements in programming languages, and is formally defined as follows:

The \lstinline!while!-statement corresponds to while-statements in other programming languages, and is formally defined as follows:
\begin{enumerate}
\item
\label{while-execution-top}
Expand All @@ -300,6 +307,9 @@ \subsection{While-Statement}\label{while-statement}
If the \lstinline!expression! of the \lstinline!while!-statement is true, the entire body of the \lstinline!while!-statement is executed (except if a \lstinline!break!-statement, see \cref{break-statement}, or a \lstinline!return!-statement, see \cref{return-statements}, is executed), and then execution proceeds at step~\ref{while-execution-top}.
\end{enumerate}

Event-generating expressions are neither allowed in the \lstinline!expression! nor in the loop body statements.
A deprecated feature is that all expressions in a \lstinline!while!-statement are implicitly inside \lstinline!noEvent!.

\subsection{Break-Statement}\label{break-statement}

The \lstinline!break!-statement\index{break@\robustinline{break}} breaks the execution of the innermost \lstinline!while!- or \lstinline!for!-loop enclosing the \lstinline!break!-statement and continues execution after the \lstinline!while!- or \lstinline!for!-loop.
Expand Down