Skip to content

Commit

Permalink
Specify that each is wrt enclosing array for its position (modelica#2648
Browse files Browse the repository at this point in the history
)

* Clarify that each is enclosing wrt its position.
* Add example.
Closes modelica#2630
  • Loading branch information
HansOlsson committed Oct 5, 2020
1 parent b365c0a commit 8d8e5da
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions chapters/inheritance.tex
Expand Up @@ -502,9 +502,10 @@ \subsection{Modifiers for Array Elements}\label{modifiers-for-array-elements}
\item
The \lstinline!each! keyword on a modifier requires that it is applied in an array
declaration/modification, and the modifier is applied individually to
each element of the array (in case of nested modifiers this implies it
each element of the enclosing array (with regard to the position of \lstinline!each!).
In case of nested modifiers this implies it
is applied individually to each element of each element of the
enclosing array; see example). If the modified element is a vector and
enclosing array; see example. If the modified element is a vector and
the modifier does not contain the \lstinline!each!-prefix, the modification is
split such that the first element in the vector is applied to the
first element of the vector of elements, the second to the second
Expand Down Expand Up @@ -551,6 +552,16 @@ \subsection{Modifiers for Array Elements}\label{modifiers-for-array-elements}
\end{lstlisting}
This implies \lstinline!b[k].c[i].a[j] = j!, \lstinline!b[k].c[i].d = i!, and \lstinline!b[k].p = k!. For \lstinline!c.a! the additional (outer) \lstinline!each! has no effect,
but it is necessary for \lstinline!c.d!.

Specifying array dimensions after the type works the same as specifying them after the variable name.
\begin{lstlisting}[language=modelica]
model F
Real fail1[2](each start={1,2}); // Illegal
Real work1[2](each start=1); // Legal
Real[2] fail2(each start={1,2}); // Illegal
Real[2] work2(each start=2); // Legal
end F;
\end{lstlisting}
\end{example}

\subsection{Final Element Modification Prevention}\label{final-element-modification-prevention}
Expand Down

0 comments on commit 8d8e5da

Please sign in to comment.