Skip to content

Commit

Permalink
Write "base class" and "short class definition" with space
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Apr 11, 2021
1 parent c840a02 commit 2c95ccc
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 81 deletions.
35 changes: 14 additions & 21 deletions chapters/annotations.tex
Expand Up @@ -356,7 +356,7 @@ \section{Annotations for Code Generation}\label{annotations-for-code-generation}
"Evaluate" "=" ( false | true )
\end{lstlisting}\end{synopsis}
\begin{semantics}
The annotation \lstinline!Evaluate! can occur in the component declaration, its type declaration, or a base-class of the type-declaration.
The annotation \lstinline!Evaluate! can occur in the component declaration, its type declaration, or a base class of the type-declaration.
In the case of multiple conflicting annotations it is handled similarly to modifiers (e.g., an \lstinline!Evaluate! annotation on the component declaration takes precedence).
In the case of hierarchical components it is applied to all components, overriding any \lstinline!Evaluate!-setting for specific components.
The annotation \lstinline!Evaluate! only has effect for a component declared with the prefix \lstinline!parameter!.
Expand Down Expand Up @@ -569,11 +569,8 @@ \section{Annotations for Graphical Objects}\label{annotations-for-graphical-obje
\end{lstlisting}
\end{example}

The graphics is specified as an ordered sequence of graphical
primitives, which are described below. First base-class contents is
drawn according to the order of the extends-clauses, and then graphical
primitives are drawn according to the order such that later objects can
cover earlier ones.
The graphics is specified as an ordered sequence of graphical primitives, which are described below.
First base class contents is drawn according to the order of the extends-clauses, and then graphical primitives are drawn according to the order such that later objects can cover earlier ones.

\begin{nonnormative}
Note that the ordered sequence is syntactically a valid Modelica annotation, although there
Expand Down Expand Up @@ -666,9 +663,8 @@ \subsubsection{Coordinate Systems}\label{coordinate-systems}
\item
The coordinate system annotation given in the class (if specified).
\item
The coordinate systems of the first base-class where the extent on the
extends-clause specifies a null-region (if any). Note that null-region
is the default for base-classes, see \cref{extends-clause}.
The coordinate systems of the first base class where the extent on the extends-clause specifies a null-region (if any).
Note that null-region is the default for base classes, see \cref{extends-clause}.
\item
The default coordinate system \lstinline!CoordinateSystem(extent = {{-100, -100}, {100, 100}})!.
\end{enumerate}
Expand Down Expand Up @@ -798,7 +794,7 @@ \subsection{Component Instance}\label{component-instance}

\subsection{Extends clause}\label{extends-clause}

Each extends-clause (and short-class-definition, as stated in \cref{annotations-for-graphical-objects}) may have layer specific annotations which describe the rendering of the base class' icon and diagram layers in the derived class.
Each extends-clause (and short class definition, as stated in \cref{annotations-for-graphical-objects}) may have layer specific annotations which describe the rendering of the base class' icon and diagram layers in the derived class.

\begin{lstlisting}[language=modelica]
record IconMap
Expand Down Expand Up @@ -1312,7 +1308,9 @@ \section{Annotations for the Graphical User Interface}\label{annotations-for-the
\end{lstlisting}%
\annotationindex{obsolete}

It indicates that the class ideally should not be used anymore and gives a message indicating the recommended action. This annotation is not inherited, the assumption is that if a class uses an obsolete class (as a base-class or as the class of one of the components) that shall be updated -- ideally without impacting users of the class. If that is not possible the current class can have also have an \lstinline!obsolete! annotation.
It indicates that the class ideally should not be used anymore and gives a message indicating the recommended action.
This annotation is not inherited, the assumption is that if a class uses an obsolete class (as a base class or as the class of one of the components) that shall be updated -- ideally without impacting users of the class.
If that is not possible the current class can have also have an \lstinline!obsolete! annotation.

A component declaration may have the following annotation:
\begin{lstlisting}[language=modelica]
Expand Down Expand Up @@ -1674,13 +1672,8 @@ \subsubsection{Conversion rules}\label{conversion-rules}
These functions can be called with literal strings or array of strings
and vectorize according to \cref{scalar-functions-applied-to-array-arguments}.

All of these convert-functions only use inheritance among user
models, and not in the library that is used for the conversion -- thus
conversions of base-classes will require multiple conversion-calls; this
ensures that the conversion is independent of the new library structure.
The name of the class used as argument to \lstinline!convertElement! and \lstinline!convertModifiers!
is similarly the old name of the class, i.e.\ the name before it is
possibly converted by \lstinline!convertClass!.
All of these convert-functions only use inheritance among user models, and not in the library that is used for the conversion -- thus conversions of base classes will require multiple conversion-calls; this ensures that the conversion is independent of the new library structure.
The name of the class used as argument to \lstinline!convertElement! and \lstinline!convertModifiers! is similarly the old name of the class, i.e.\ the name before it is possibly converted by \lstinline!convertClass!.

\begin{nonnormative}
Specifying conversions using the old name of a class allows the conversion to be done without access to the old
Expand Down Expand Up @@ -1795,7 +1788,8 @@ \subsubsection{Conversion rules}\label{conversion-rules}
This can be used to handle the case where the default value was changed.
\end{nonnormative}

Converting modifiers with cardinality is used to remove the deprecated operator \lstinline!cardinality! from model libraries, and replace tests on cardinality in models by parameters explicitly enabling the different cases. The case where the old class is used as a base-class, and there exist outside connections to \lstinline!a!, and there is \lstinline!convertModifiers! involving the cardinality of \lstinline!a! is not handled.
Converting modifiers with cardinality is used to remove the deprecated operator \lstinline!cardinality! from model libraries, and replace tests on cardinality in models by parameters explicitly enabling the different cases.
The case where the old class is used as a base class, and there exist outside connections to \lstinline!a!, and there is \lstinline!convertModifiers! involving the cardinality of \lstinline!a! is not handled.

\begin{nonnormative}
Having a parameter for explicitly enabling the different cases means that instead of model \lstinline!A! internally testing if its
Expand Down Expand Up @@ -1862,8 +1856,7 @@ \subsubsection{Conversion rules}\label{conversion-rules}
Boolean b=a.quasiStatic;
end B;
\end{lstlisting}
The \lstinline!convertElement! call for \lstinline!DC_ElectricalExcited! is needed to avoid relying on base-classes
in the original library where \lstinline!DC_ElectricalExcited! inherits from \lstinline!PartialBasicDCMachine!.
The \lstinline!convertElement! call for \lstinline!DC_ElectricalExcited! is needed to avoid relying on base classes in the original library where \lstinline!DC_ElectricalExcited! inherits from \lstinline!PartialBasicDCMachine!.
However, the inheritance among the models to convert (in this case \lstinline!B! inherits from \lstinline!A!) should be handled.
\end{example}

Expand Down
30 changes: 11 additions & 19 deletions chapters/classes.tex
Expand Up @@ -17,9 +17,8 @@ \section{Access Control -- Public and Protected Elements}\label{access-control-p
Members of a Modelica class can have two levels of visibility: \lstinline!public!\indexinline{public} or \lstinline!protected!\indexinline{protected}.
The default is \lstinline!public! if nothing else is specified.

A protected element, \lstinline!P!, in classes and components shall not be accessed via dot notation (e.g., \lstinline!A.P!, \lstinline!a.P!, \lstinline!a[1].P!, \lstinline!a.b.P!,
\lstinline!.A.P!; but there is no restriction on using \lstinline!P! or \lstinline!P.x! for a protected element \lstinline!P!). They shall not be modified or redeclared except for
modifiers applied to protected elements in a base-class modification (not inside any component or class) and the modifier on the declaration of the protected element.
A protected element, \lstinline!P!, in classes and components shall not be accessed via dot notation (e.g., \lstinline!A.P!, \lstinline!a.P!, \lstinline!a[1].P!, \lstinline!a.b.P!, \lstinline!.A.P!; but there is no restriction on using \lstinline!P! or \lstinline!P.x! for a protected element \lstinline!P!).
They shall not be modified or redeclared except for modifiers applied to protected elements in a base class modification (not inside any component or class) and the modifier on the declaration of the protected element.

\begin{example}
\begin{lstlisting}[language=modelica]
Expand Down Expand Up @@ -164,7 +163,7 @@ \subsection{Component Declaration Static Semantics}\label{component-declaration-

% Seems sufficient to just have \indexinline variant of 'partial' in index.
A class defined with \lstinline!partial!\indexinline{partial} in the \lstinline[language=grammar]!class-prefixes! is called a \firstuse{partial} class.
Such a class is allowed to be incomplete, and cannot be instantiated in a simulation model; useful, e.g., as a base-class.
Such a class is allowed to be incomplete, and cannot be instantiated in a simulation model; useful, e.g., as a base class.

If the \lstinline[language=grammar]!type-specifier! of the component does not denote a built-in type, the name of the type is looked up (\cref{static-name-lookup}).
The found type is flattened with a new environment and the partially flattened enclosing class of the component.
Expand Down Expand Up @@ -645,7 +644,7 @@ \subsection{Short Class Definitions}\label{short-class-definitions}
replaceable model LoadError
extends Resistor(R=R);
// Gives the singular equation R=R, since the right-hand side R
// is searched for in LoadError and found in its base-class Resistor.
// is searched for in LoadError and found in its base class Resistor.
end LoadError constrainedby TwoPin;
encapsulated model Load2=.Resistor(R=2); // Ok
encapsulated model LoadR=.Resistor(R=R); // Illegal
Expand All @@ -670,11 +669,8 @@ \subsection{Short Class Definitions}\label{short-class-definitions}
'end' TN;
\end{lstlisting}

Such an array class has exactly one anonymous component (\_); see also
\cref{restriction-on-combining-base-classes-and-other-elements}.
When a component of such an array class type is
flattened, the resulting flattened component type is an array type with
the same dimensions as \_ and with the optional modifier applied.
Such an array class has exactly one anonymous component (\_); see also \cref{restriction-on-combining-base-classes-and-other-elements}.
When a component of such an array class type is flattened, the resulting flattened component type is an array type with the same dimensions as \_ and with the optional modifier applied.

\begin{example}
The types of \lstinline!f1! and \lstinline!f2! are identical:
Expand All @@ -694,13 +690,9 @@ \subsection{Short Class Definitions}\label{short-class-definitions}
\end{lstlisting}
\end{example}

If a short class definition does not specify any specialized class the
new class definition will inherit the specialized class (this rule
applies iteratively and also for redeclare).
If a short class definition does not specify any specialized class the new class definition will inherit the specialized class (this rule applies iteratively and also for redeclare).

A base-prefix applied in the short-class definition does not influence
its type, but is applied to components declared of this type or types
derived from it; see also \cref{restriction-on-combining-base-classes-and-other-elements}.
A base-prefix applied in the short class definition does not influence its type, but is applied to components declared of this type or types derived from it; see also \cref{restriction-on-combining-base-classes-and-other-elements}.

\begin{example}
\begin{lstlisting}[language=modelica]
Expand All @@ -718,9 +710,9 @@ \subsection{Short Class Definitions}\label{short-class-definitions}
\end{lstlisting}
\end{example}

\subsection{Restriction on combining base-classes and other elements}\label{restriction-on-combining-base-classes-and-other-elements}
\subsection{Restriction on combining base classes and other elements}\label{restriction-on-combining-base-classes-and-other-elements}

It is not legal to combine other components or base-classes with an extends from an array class, a class with non-empty base-prefix, a \firstuse{simple type}\index{simple type} (\lstinline!Real!, \lstinline!Boolean!, \lstinline!Integer!, \lstinline!String! and enumeration types), or any class transitively extending from an array class, a class with non-empty base-prefix, or a simple type.
It is not legal to combine other components or base classes with an extends from an array class, a class with non-empty base-prefix, a \firstuse{simple type}\index{simple type} (\lstinline!Real!, \lstinline!Boolean!, \lstinline!Integer!, \lstinline!String! and enumeration types), or any class transitively extending from an array class, a class with non-empty base-prefix, or a simple type.

\begin{example}
\begin{lstlisting}[language=modelica]
Expand Down Expand Up @@ -1018,7 +1010,7 @@ \section{Balanced Models}\label{balanced-models}
If \lstinline!use_support=true!, there are two additional equations for \lstinline!support.phi! and \lstinline!support.tau! via the modifier.
\end{example}
\item
In other cases (declaration of a component of a \lstinline!model! or \lstinline!block! class, modifiers on extends, and modifier on short-class-definitions): Modifiers for components shall only contain redeclarations of replaceable elements and binding equations. The binding equations in modifiers for components may in these cases only be for parameters, constants, inputs and variables having a default binding equation.
In other cases (declaration of a component of a \lstinline!model! or \lstinline!block! class, modifiers on extends, and modifier on short class definitions): Modifiers for components shall only contain redeclarations of replaceable elements and binding equations. The binding equations in modifiers for components may in these cases only be for parameters, constants, inputs and variables having a default binding equation.
\item
All non-partial \lstinline!model! and \lstinline!block! classes must be locally balanced.
\begin{nonnormative}
Expand Down
3 changes: 2 additions & 1 deletion chapters/functions.tex
Expand Up @@ -801,7 +801,8 @@ \subsection{Flexible Array Sizes and Resizing of Arrays in Functions}\label{flex

\subsection{Scalar Functions Applied to Array Arguments}\label{scalar-functions-applied-to-array-arguments}

Functions with one scalar return value can be applied to arrays element-wise, e.g.\ if \lstinline!A! is a vector of reals, then \lstinline!sin(A)! is a vector where each element is the result of applying the function \lstinline!sin! to the corresponding element in \lstinline!A!. Only \lstinline!function! classes that are transitively non-replaceable (\cref{transitively-non-replaceable} and \cref{restrictions-on-base-classes-and-constraining-types-to-be-transitively-non-replaceable}) may be called vectorized.
Functions with one scalar return value can be applied to arrays element-wise, e.g.\ if \lstinline!A! is a vector of reals, then \lstinline!sin(A)! is a vector where each element is the result of applying the function \lstinline!sin! to the corresponding element in \lstinline!A!.
Only \lstinline!function! classes that are transitively non-replaceable (\cref{transitively-non-replaceable} and \cref{restrictions-on-base-classes-and-constraining-types-to-be-transitively-non-replaceable}) may be called vectorized.

Consider the expression \lstinline!f(arg1, $\ldots$, argn)!, an application of the function \lstinline!f! to the arguments \lstinline!arg1!, \ldots, \lstinline!argn!.
Potential vectorization of this call is defined as follows.
Expand Down
12 changes: 5 additions & 7 deletions chapters/inheritance.tex
Expand Up @@ -232,7 +232,8 @@ \subsection{Restrictions on the Kind of Base Class}\label{restrictions-on-the-ki

\subsection{Restrictions on Base Classes and Constraining Types to be Transitively Non-Replaceable}\label{restrictions-on-base-classes-and-constraining-types-to-be-transitively-non-replaceable}

The class name used after \lstinline!extends! for base-classes and for constraining classes must use a class reference considered transitively non-replaceable, see definition in \cref{transitively-non-replaceable}. For a replaceable component declaration without constraining clause the class must use a class reference considered transitively non-replaceable.
The class name used after \lstinline!extends! for base classes and for constraining classes must use a class reference considered transitively non-replaceable, see definition in \cref{transitively-non-replaceable}.
For a replaceable component declaration without constraining clause the class must use a class reference considered transitively non-replaceable.

\begin{nonnormative}
The requirement to use a transitively non-replaceable name excludes the long form of redeclare, i.e.\ \lstinline!redeclare model extends M $\ldots$! where \lstinline!M! must be an inherited replaceable class.
Expand Down Expand Up @@ -579,7 +580,7 @@ \section{Redeclaration}\label{redeclaration}
A \lstinline!redeclare! construct as an element replaces the declaration of a local class or component with another declaration.
Both \lstinline!redeclare! constructs work in the same way.
The \lstinline!redeclare! construct as an element requires that the element is inherited, and cannot be combined with a modifier of the same element in the extends-clause.
For modifiers the redeclare of classes uses a special short-class-definition construct; that is a subset of normal class definitions and semantically behave as the corresponding class-definition.
For modifiers the redeclare of classes uses a special short class definition construct; that is a subset of normal class definitions and semantically behave as the corresponding class-definition.

A modifier with the keyword \lstinline!replaceable!\indexinline{replaceable} is automatically seen as being a \lstinline!redeclare!.

Expand Down Expand Up @@ -801,15 +802,12 @@ \subsection{Constraining Type}\label{constraining-type}
and in any subsequent redeclaration. The precedence order is that
declaration modifiers override constraining type modifiers.

If the \lstinline!constraining-clause! is not present in the original declaration
(i.e., the non-redeclared declaration):
If the \lstinline!constraining-clause! is not present in the original declaration (i.e., the non-redeclared declaration):
\begin{itemize}
\item
The type of the declaration is also used as a constraining type.
\item
The modifiers for subsequent redeclarations and constraining type are
the modifiers on the component or short-class-definition if that is
used in the original declaration, otherwise empty.
The modifiers for subsequent redeclarations and constraining type are the modifiers on the component or short class definition if that is used in the original declaration, otherwise empty.
\end{itemize}

The syntax of a constraining-clause\indexinline{constrainedby} is as follows:
Expand Down

0 comments on commit 2c95ccc

Please sign in to comment.