Skip to content

Commit

Permalink
Clean up example "Variables with array dimensions"
Browse files Browse the repository at this point in the history
Fixes modelica#2855.

(I have checked that the longer lines don't wrap.)
  • Loading branch information
henrikt-ma committed Feb 16, 2021
1 parent bd035cc commit 000557c
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions chapters/classes.tex
Expand Up @@ -180,22 +180,22 @@ \subsection{Component Declaration Static Semantics}\label{component-declaration-

Array dimensions shall be scalar non-negative parameter expressions of type \lstinline!Integer!, a reference to a type (which must an enumeration type or \lstinline!Boolean!, see \cref{enumeration-types}), or the colon operator denoting that the array dimension is left unspecified (see \cref{array-declarations}). All variants can also be part of short class definitions.

\begin{nonnormative}
Example of variables with array dimensions.
\begin{example}
Variables with array dimensions:
\begin{lstlisting}[language=modelica]
model ArrayVariants
type T=Real[:]; // Unspecified size for type
parameter T x=ones(4);
parameter T y[3]=ones(3, 4);
parameter Real a[2]=ones(2); // Specified using Integer
parameter Real b[2, 0]=ones(2, 0); // Size 0 is allowed
parameter Real c[:]=ones(0); // Unspecified size for variable
parameter Integer n=0;
Real x[n*2]=cat(1,ones(n),zeros(n)};// Parameter expressions are allowed
Boolean notV[Boolean]={true,false}; // Indexing with type
type T = Real[:]; // Unspecified size for type
parameter T x = ones(4);
parameter T y[3] = ones(3, 4);
parameter Real a[2] = ones(2); // Specified using Integer
parameter Real b[2, 0] = ones(2, 0); // Size 0 is allowed
parameter Real c[:] = ones(0); // Unspecified size for variable
parameter Integer n = 0;
Real z[n*2] = cat(1, ones(n), zeros(n));// Parameter expressions are allowed
Boolean notV[Boolean] = {true, false}; // Indexing with type
end ArrayVariants;
\end{lstlisting}
\end{nonnormative}
\end{example}

The rules for components in functions are described in \cref{function-as-a-specialized-class}.

Expand Down

0 comments on commit 000557c

Please sign in to comment.