From 0787fb9ef401b1d0925eb850e799175b00429e18 Mon Sep 17 00:00:00 2001 From: Henrik Tidefelt Date: Wed, 14 Apr 2021 23:38:49 +0200 Subject: [PATCH] Use correct variants of "loop" --- chapters/classes.tex | 8 ++++++-- chapters/dae.tex | 2 +- chapters/equations.tex | 7 ++++++- chapters/revisions.tex | 2 +- chapters/scoping.tex | 4 +--- chapters/statements.tex | 6 ++++-- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/chapters/classes.tex b/chapters/classes.tex index 496bd2d3f..664466f88 100644 --- a/chapters/classes.tex +++ b/chapters/classes.tex @@ -972,7 +972,9 @@ \section{Balanced Models}\label{balanced-models} \end{definition} \begin{nonnormative} -Here, \emph{legal values} must respect final bindings and min/max-restrictions. A tool shall verify the \emph{locally balanced} property for the actual values of parameters and constants in the simulation model. It is a quality of implementation for a tool to verify this property in general, due to arrays of (locally) undefined sizes, conditional declarations, for-loops etc. +Here, \emph{legal values} must respect final bindings and min/max-restrictions. +A tool shall verify the \emph{locally balanced} property for the actual values of parameters and constants in the simulation model. +It is a quality of implementation for a tool to verify this property in general, due to arrays of (locally) undefined sizes, conditional declarations, \lstinline!for!-loops etc. \end{nonnormative} \begin{definition}[Globally balanced]\index{globally balanced}\index{balanced!globally} @@ -1493,7 +1495,9 @@ \subsection{Enumeration Types}\label{enumeration-types} \end{lstlisting} \end{example} -An enumeration type is a simple type and the attributes are defined in \cref{attributes-of-enumeration-types}. The \lstinline!Boolean! type name or an enumeration type name can be used to specify the dimension range for a dimension in an array declaration and to specify the range in a for-loop range expression; see \cref{types-as-iteration-ranges}. An element of an enumeration type can be accessed in an expression. +An enumeration type is a simple type and the attributes are defined in \cref{attributes-of-enumeration-types}. +The \lstinline!Boolean! type name or an enumeration type name can be used to specify the dimension range for a dimension in an array declaration and to specify the range in a \lstinline!for!-loop range expression; see \cref{types-as-iteration-ranges}. +An element of an enumeration type can be accessed in an expression. \begin{nonnormative} Uses of elements of enumeration type in expressions include indexing into an array. diff --git a/chapters/dae.tex b/chapters/dae.tex index 63522a9cd..a1ed87e0f 100644 --- a/chapters/dae.tex +++ b/chapters/dae.tex @@ -142,7 +142,7 @@ \chapter{Modelica DAE Representation}\label{modelica-dae-representation} end loop \end{lstlisting} -Clocked variables are handled similarly as $z$ and $m$ (depending on type), but using \lstinline!previous! instead of \lstinline!pre! and only solved in the first iteration of the event-loop. +Clocked variables are handled similarly as $z$ and $m$ (depending on type), but using \lstinline!previous! instead of \lstinline!pre! and only solved in the first event iteration. Solving \eqref{eq:hydrid-dae} for the unknowns is non-trivial, because this set of equations contains not only \lstinline!Real!, but also discrete-valued unknowns. Usually, in a first step these equations are sorted and in many cases the discrete-valued unknowns $m$ can be just computed by a forward evaluation sequence. diff --git a/chapters/equations.tex b/chapters/equations.tex index 907a7e567..bd3b17d46 100644 --- a/chapters/equations.tex +++ b/chapters/equations.tex @@ -111,7 +111,12 @@ \subsection{For-Equations -- Repetitive Equation Structures}\label{for-equations \subsubsection{Explicit Iteration Ranges of For-Equations}\label{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 \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 for-loop. +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 \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. \begin{example} \begin{lstlisting}[language=modelica] diff --git a/chapters/revisions.tex b/chapters/revisions.tex index 115665ab8..96b07f4f2 100644 --- a/chapters/revisions.tex +++ b/chapters/revisions.tex @@ -2752,7 +2752,7 @@ \subsection{Main Changes in Modelica 1.3}\label{main-changes-in-modelica-1-3} \item Improved semantic definition of array expressions. \item - Defined scope of for-loop variables. + Defined scope of \lstinline!for!-loop variables. \end{itemize} \subsection{Main Changes in Modelica 1.2}\label{main-changes-in-modelica-1-2} diff --git a/chapters/scoping.tex b/chapters/scoping.tex index 786845a38..1d8cd1981 100644 --- a/chapters/scoping.tex +++ b/chapters/scoping.tex @@ -69,9 +69,7 @@ \subsection{Simple Name Lookup}\label{simple-name-lookup} In the latter case the lookup stops except for the predefined types, functions and operators defined in this specification. For these cases the lookup continues in the global scope, where they are defined. -The iteration variables are the implicitly declared iteration variable(s) if inside -the body of a for-loop, \cref{for-equations-repetitive-equation-structures} and \cref{for-statement}, -or the body of a reduction expression, \cref{reduction-functions-and-operators}. +The iteration variables are the implicitly declared iteration variable(s) if inside the body of a \lstinline!for!-loop, \cref{for-equations-repetitive-equation-structures} and \cref{for-statement}, or the body of a reduction expression, \cref{reduction-functions-and-operators}. Reference to variables successfully looked up in an enclosing class is only allowed for variables declared as \lstinline!constant!. The values of modifiers are thus resolved in the \emph{instance} scope of which the modifier appears; if the use is in a modifier on a short class definition, see \cref{short-class-definitions}. diff --git a/chapters/statements.tex b/chapters/statements.tex index 85fff2024..a43ada554 100644 --- a/chapters/statements.tex +++ b/chapters/statements.tex @@ -249,11 +249,13 @@ \subsubsection{Implicit Iteration Ranges}\label{implicit-iteration-ranges} \end{lstlisting} \end{example} -The size of an array -- the iteration range -- is evaluated on entry to the for-loop and the array size shall not change during the execution of the for-loop. +The size of an array -- the iteration range -- is evaluated on entry to the \lstinline!for!-loop and the array size shall not change during the execution of the \lstinline!for!-loop. \subsubsection{Types as Iteration Ranges}\label{types-as-iteration-ranges} -The iteration range can be specified as \lstinline!Boolean! or as an enumeration type. This means iteration over the type from min to max, i.e.\ for \lstinline!Boolean! it is the same as \lstinline!false:true! and for an enumeration \lstinline!E! it is the same as \lstinline!E.min:E.max!. This can be used for \lstinline!for! loops and reduction expressions. +The iteration range can be specified as \lstinline!Boolean! or as an enumeration type. +This means iteration over the type from min to max, i.e.\ for \lstinline!Boolean! it is the same as \lstinline!false:true! and for an enumeration \lstinline!E! it is the same as \lstinline!E.min:E.max!. +This can be used for \lstinline!for!-loops and reduction expressions. \begin{example} \begin{lstlisting}[language=modelica]