Skip to content

Commit

Permalink
Clean up non-normative content in overloaded.tex
Browse files Browse the repository at this point in the history
  • Loading branch information
henrikt-ma committed Apr 29, 2020
1 parent 5188e1b commit 35cab78
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 77 deletions.
153 changes: 76 additions & 77 deletions chapters/overloaded.tex
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ \chapter{Overloaded Operators}\doublelabel{overloaded-operators}
using the specialized class \lstinline!operator! (a restricted class
similar to \lstinline!package!, see \autoref{specialized-classes}) comprised of functions
implementing different variants of the operation for the record class in
which the respective \lstinline!operator! definition resides. {[}\emph{The
overloading is defined in such a way that ambiguities are not allowed
and give an error. Furthermore, it is sufficient to define overloading
for scalars. Overloaded array operations are automatically deduced from
the overloaded scalar operations.}{]} The \lstinline!operator! keyword is
followed by the name of the operation:
which the respective \lstinline!operator! definition resides.

\begin{nonnormative}
The overloading is defined in such a way that ambiguities are not allowed and give an error. Furthermore, it is sufficient to define overloading for scalars.
Overloaded array operations are automatically deduced from the overloaded scalar operations.
\end{nonnormative}

The \lstinline!operator! keyword is followed by the name of the operation:
% This was something weird that could be seen as a table originally,
% that is somewhat awkward - but keeping it.
%
Expand Down Expand Up @@ -142,13 +143,17 @@ \section{Overloaded Constructors}\doublelabel{overloaded-constructors}
one output component, which shall be of the operator record class C.
\item
For an operator recordclass there shall not exist any potential call
that lead to multiple matches in (1) above. {[}\emph{How to verify
this is not specified.}{]}
that lead to multiple matches in (1) above.
\begin{nonnormative}
How to verify this is not specified.
\end{nonnormative}
\item
For a pair of operator record classes C and D and components c and d
of these classes both of C.'constructor' (d) and D.'constructor' (c)
shall not both be legal {[}\emph{, so one of the two definitions must
be removed}{]}\emph{.}
For a pair of operator record classes \lstinline!C! and \lstinline!D! and components \lstinline!c! and \lstinline!d!
of these classes both of \lstinline!C.'constructor'(d)! and \lstinline!D.'constructor'(c)!
shall not both be legal.
\begin{nonnormative}
Hence, one of the two definitions must be removed.
\end{nonnormative}
\end{itemize}

\begin{nonnormative}
Expand All @@ -175,77 +180,74 @@ \section{Overloaded Constructors}\doublelabel{overloaded-constructors}

\section{Overloaded String Conversions}\doublelabel{overloaded-string-conversions}

Consider an expression String($A_1$,
$a_{2}$,\ldots{}, $a_{k}$, $b_{1}$=
$w_{1}$ ,\ldots{}, $b_{p}$= $w_{p}$), $k\ge 1$ where $A_1$ is an element of class A.
Consider an expression \lstinline[mathescape=true]!String($A_1$, $a_{2}$, $\ldots$, $a_{k}$, $b_{1}$=$w_{1}$, $\ldots$, $b_{p}$=$w_{p}$)!,
$k \ge 1$ where $A_1$ is an element of class \lstinline!A!.

\begin{enumerate}
\item
If A is a predefined \underline{type}, i.e., Boolean, Integer, Real, String or
If \lstinline!A! is a predefined type, i.e., \lstinline!Boolean!, \lstinline!Integer!, \lstinline!Real!, \lstinline!String! or
an enumeration, or a type derived from them, then the corresponding
built-in operation is performed.
\item
If A is an operator \underline{record class} and there exists a unique function
f in A.'String' such that ($A_1$,
$a_{2}$,\ldots{}, $a_{k}$, $b_{1}$=
$w_{1}$ ,\ldots{}, $b_{p}$= $w_{p}$)
is a valid match for f, then String($A_1$,
$a_{2}$,\ldots{}, $a_{k}$, $b_{1}$=
$w_{1}$ ,\ldots{}, $b_{p}$= $w_{p}$)
If \lstinline!A! is an operator record class and there exists a unique function
$f$ in \lstinline!A.'String'! such that
\lstinline[mathescape=true]!A.'String'.$f$($A_1$, $a_{2}$, $\ldots$, $a_{k}$, $b_{1}$=$w_{1}$, $\ldots$, $b_{p}$=$w_{p}$)!
is a valid match for $f$, then
\lstinline[mathescape=true]!String($A_1$, $a_{2}$, $\ldots$, $a_{k}$, $b_{1}$=$w_{1}$, $\ldots$, $b_{p}$=$w_{p}$)!
is evaluated to\\
A.'String'.f($A_1$, $a_{2}$,\ldots{},
$a_{k}$, $b_{1}$= $w_{1}$ ,\ldots{},
$b_{p}$= $w_{p}$).
\lstinline[mathescape=true]!A.'String'.$f$($A_1$, $a_{2}$, $\ldots$, $a_{k}$, $b_{1}$=$w_{1}$, $\ldots$, $b_{p}$=$w_{p}$)!.
\item
Otherwise the expression is erroneous.
\end{enumerate}

Restrictions:
\begin{itemize}
\item
The operator A.'String' shall only contain functions that declare one
output component, which shall be of the String type, and the first
input argument shall be of the operator record class A.
The operator \lstinline!A.'String'! shall only contain functions that declare one
output component, which shall be of the \lstinline!String! type, and the first
input argument shall be of the operator record class \lstinline!A!.
\item
For an operator record class there shall not exist any call that lead
to multiple matches in (2) above. {[}\emph{How to verify this is not
specified.}{]}
to multiple matches in (2) above.
\begin{nonnormative}
How to verify this is not specified.
\end{nonnormative}
\end{itemize}

\section{Overloaded Binary Operations}\doublelabel{overloaded-binary-operations}

Let \emph{op} denote a binary operator and consider an expression
\emph{a op b} where \emph{a} is an instance or array of instances of
class \emph{A} and \emph{b} is an instance or array of instances of
class \emph{B}.
Let $\mathit{op}$ denote a binary operator and consider an expression
\lstinline[mathescape=true]!a $\mathit{op}$ b! where \lstinline!a! is an instance or array of instances of
class \lstinline!A! and \lstinline!b! is an instance or array of instances of
class \lstinline!B!.

\begin{enumerate}
\item
If \emph{A} and \emph{B} are predefined types of such, then the
If \lstinline!A! and \lstinline!B! are predefined types of such, then the
corresponding built-in operation is performed.
\item
Otherwise, if there exists \underline{exactly one} function \emph{f} in the
union of \emph{A}.\emph{op} and \emph{B.op} such that
f(\emph{a},\emph{b}) is a valid match for the function \emph{f} , then
\emph{a op b} is evaluated using this function. It is an error, if
multiple functions match. If A is not an operator record class, A.op
is seen as the empty set, and similarly for B. {[}\emph{Having a union
of the operators ensures that if A and B are the same, each function
only appears once.}{]}
Otherwise, if there exists \emph{exactly one} function $f$ in the
union of \lstinline[mathescape=true]!A.$\mathit{op}$! and \lstinline[mathescape=true]!B.$\mathit{op}$! such that
\lstinline[mathescape=true]!$f$(a, b)! is a valid match for the function $f$, then
\lstinline[mathescape=true]!a $\mathit{op}$ b! is evaluated using this function. It is an error, if
multiple functions match. If \lstinline!A! is not an operator record class, \lstinline[mathescape=true]!A.$\mathit{op}$!
is seen as the empty set, and similarly for \lstinline!B!.
\begin{nonnormative}
Having a union of the operators ensures that if \lstinline!A! and \lstinline!B! are the same, each function only appears once.
\end{nonnormative}
\item
Otherwise, consider the set given by \emph{f} in \emph{A}.\emph{op}
and an operator record class \emph{C} (different from B) with a
constructor, g, such that C.'constructor'.g(b) is a valid match, and
f(a, C.'constructor'.g(b)) is a valid match; and another set given by
\emph{f} in \emph{B}.\emph{op} and an operator record class \emph{D}
(different from A) with a constructor, h, such that
D.'constructor'.h(a) is a valid match and f(D.'constructor'.h(a), b)
Otherwise, consider the set given by $f$ in \lstinline[mathescape=true]!A.$\mathit{op}$!
and an operator record class \lstinline!C! (different from \lstinline!B!) with a
constructor, $g$, such that \lstinline[mathescape=true]!C.'constructor'.$g$(b)! is a valid match, and
\lstinline[mathescape=true]!f(a, C.'constructor'.$g$(b))! is a valid match; and another set given by
$f$ in \lstinline[mathescape=true]!B.$\mathit{op}$! and an operator record class \lstinline!D!
(different from \lstinline!A!) with a constructor, $h$, such that
\lstinline[mathescape=true]!D.'constructor'.$h$(a)! is a valid match and \lstinline[mathescape=true]!$f$(D.'constructor'.$h$(a), b)!
is a valid match. If the sum of the sizes of these sets is one this
gives the unique match. If the sum of the sizes is larger than one it
is an error.

\begin{nonnormative}
Informally, this means: If there is no direct match of \lstinline!a op b!, then it is tried to find a direct match by automatic type casts
Informally, this means: If there is no direct match of \lstinline[mathescape=true]!a $\mathit{op}$ b!, then it is tried to find a direct match by automatic type casts
of \lstinline!a! or \lstinline!b!, by converting either \lstinline!a! or \lstinline!b! to the needed
type using an appropriate constructor function from one of the
operator record classes used as arguments of the overloaded \lstinline!op!
Expand All @@ -257,23 +259,22 @@ \section{Overloaded Binary Operations}\doublelabel{overloaded-binary-operations}
// Complex.'*'.multiply(Complex.'constructor'.fromReal(a),b);
\end{lstlisting}
\end{nonnormative}

\item
Otherwise, if a or b is an \underline{array expression}, then the expression is
Otherwise, if \lstinline!a! or \lstinline!b! is an array expression, then the expression is
conceptually evaluated according to the rules of \autoref{scalar-vector-matrix-and-array-operator-functions} with the
following exceptions concerning \autoref{matrix-and-vector-multiplication-of-numeric-arrays}:

\begin{enumerate}
\def\labelenumii{(\alph{enumii})}
\item
vector*vector should be left undefined {[}\emph{as the scalar
product of \autoref{tab:product} does not generalize to the expected
linear and conjugate linear scalar product of complex
numbers}{]}\emph{.}
vector*vector should be left undefined.
\begin{nonnormative}
The scalar product of \autoref{tab:product} does not generalize to the expected linear and conjugate linear scalar product of complex numbers.
\end{nonnormative}
\item
vector*matrix should be left undefined {[}\emph{as the corresponding
definition of \autoref{tab:product} does not generalize to complex
numbers in the expected way}{]}.
vector*matrix should be left undefined.
\begin{nonnormative}
The corresponding definition of \autoref{tab:product} does not generalize to complex numbers in the expected way.
\end{nonnormative}
\item
If the inner dimension for matrix*vector or matrix*matrix is zero,
this uses the overloaded \lstinline!'0'! operator of the result array element
Expand Down Expand Up @@ -302,28 +303,27 @@ \section{Overloaded Binary Operations}\doublelabel{overloaded-binary-operations}
class, and the first two inputs shall not have default values, and all
inputs after the first two must have default values.
\item
For an operator record class there shall not exist {any}
{[}\emph{potential}{]} call that lead to multiple matches in (2)
above\emph{.}
For an operator record class there shall not exist any
(potential) call that lead to multiple matches in (2) above.
\end{itemize}

\section{Overloaded Unary Operations}\doublelabel{overloaded-unary-operations}

Let \emph{op} denote a unary operator and consider an expression
\emph{op a} where \emph{a} is an instance or array of instances of class
\emph{A}. Then \emph{op a} is evaluated in the following way.
Let $\mathit{op}$ denote a unary operator and consider an expression
\lstinline[mathescape=true]!$\mathit{op}$ a! where \lstinline!a! is an instance or array of instances of class
\lstinline!A!. Then \lstinline[mathescape=true]!$\mathit{op}$ a! is evaluated in the following way.

\begin{enumerate}
\item
If \emph{A} is a \underline{predefined type}, then the corresponding built-in
If \lstinline!A! is a predefined type, then the corresponding built-in
operation is performed.
\item
If \emph{A} is an \underline{operator record class} and there exists a {unique}
function \emph{f} in \emph{A.op} such that \emph{A.op.f(a)} is a valid
match, then \emph{op a} is evaluated to \emph{A.op.f(a)}. It is an
If \lstinline!A! is an operator record class and there exists a unique
function $f$ in \lstinline[mathescape=true]!A.$\mathit{op}$! such that \lstinline[mathescape=true]!A.$\mathit{op}$.$f$(a)! is a valid
match, then \lstinline[mathescape=true]!$\mathit{op}$ a! is evaluated to \lstinline[mathescape=true]!A.$\mathit{op}$.$f$(a)!. It is an
error, if there are multiple valid matches.
\item
Otherwise, if \emph{a} is an \underline{array expression}, then the expression
Otherwise, if \lstinline!a! is an array expression, then the expression
is conceptually evaluated according to the rules of \autoref{scalar-vector-matrix-and-array-operator-functions}.
\item
Otherwise the expression is erroneous.
Expand All @@ -337,9 +337,8 @@ \section{Overloaded Unary Operations}\doublelabel{overloaded-unary-operations}
arrays of such) and does not have a default value, and all inputs
after the first one must have default values.
\item
For an operator record class there shall not exist \underline{any}
{[}\emph{potential}{]} call that lead to multiple matches in (2)
above.
For an operator record class there shall not exist any
(potential) call that lead to multiple matches in (2) above.
\item
A binary and/or unary operator-class may only contain functions that
are allowed for this binary and/or unary operator-class; and in case
Expand Down
1 change: 1 addition & 0 deletions chapters/synchronous.tex
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ \subsection{Clocks and Clocked Variables}\doublelabel{clocks-and-clocked-variabl
\includegraphics[width=3in,height=1.875in]{piecewise}
\end{tabular}&\begin{tabular}{p{7cm}}\textbf{Piecewise-constant variables (see \autoref{discrete-time-expressions})}

% henrikt-ma: Get rid of the use of \underline below.
Variables \textbf{m}(t) of base type Real, Integer, Boolean,
enumeration, and String that are \underline{constant} inside each interval
t\textsubscript{i} $\le$ t \textless{} t\textsubscript{i+1} (= piecewise
Expand Down

0 comments on commit 35cab78

Please sign in to comment.