Skip to content

Commit

Permalink
Update for-statement to refer to for-equation and clarify evaluation. (
Browse files Browse the repository at this point in the history
…modelica#2391)

* Update for-statement to refer to for-equation and clarify evaluation.
Closes modelica#2205
Closes modelica#2208
  • Loading branch information
HansOlsson authored and christoff-buerger committed Oct 3, 2019
1 parent 79bc165 commit b288f7d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
13 changes: 8 additions & 5 deletions chapters/equations.tex
Expand Up @@ -103,15 +103,17 @@ \subsection{For-Equations -- Repetitive Equation Structures}\doublelabel{for-equ
for IDENT in expression loop
\end{lstlisting}

The \lstinline!expression! of a for-equation shall be a vector expression. It is
evaluated once for each for-equation, and is evaluated in the scope
\subsubsection{Explicit Iteration Ranges of For-Equations}\doublelabel{explicit-iteration-ranges-of-for-equations}
The \lstinline!expression! of a 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 for-equation, and is evaluated in the scope
immediately enclosing the for-equation. The expression of a for-equation
shall be a parameter expression. The iteration range of a for-equation
can also be specified as Boolean or as an enumeration type, see
\autoref{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. The
loop-variable has the same type as the type of the elements of the
vector expression.
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 for-loop.

{[}\emph{Example}:
\begin{lstlisting}[language=modelica]
Expand All @@ -136,6 +138,7 @@ \subsection{For-Equations -- Repetitive Equation Structures}\doublelabel{for-equ
\end{lstlisting}
{]}


\subsubsection{Implicit Iteration Ranges of For-Equations}\doublelabel{implicit-iteration-ranges-of-for-equations}

The iteration range of a loop variable may sometimes be inferred from
Expand Down
8 changes: 2 additions & 6 deletions chapters/statements.tex
Expand Up @@ -193,12 +193,8 @@ \subsection{For-statement}\doublelabel{for-statement}
\begin{lstlisting}[language=modelica]
for IDENT in expression loop
\end{lstlisting}
The \lstinline!expression! of a for-statement shall be a vector expression. It is
evaluated once for each for-statement, and is evaluated in the scope
immediately enclosing the for-statement. The loop-variable (\lstinline!IDENT!) is in
scope inside the loop-construct and shall not be assigned to. The
loop-variable has the same type as the type of the elements of the
vector expression.
The rules for for-statements are the same as for for-expressions in \autoref{explicit-iteration-ranges-of-for-equations} -
except that the \lstinline!expression! of a for-statement is not restricted to a parameter-expression.

{[}\emph{Example}:

Expand Down

0 comments on commit b288f7d

Please sign in to comment.