diff --git a/chapters/classes.tex b/chapters/classes.tex index af4969948..a0b651de4 100644 --- a/chapters/classes.tex +++ b/chapters/classes.tex @@ -801,7 +801,7 @@ \section{Specialized Classes}\label{specialized-classes} See \cref{function-as-a-specialized-class} for restrictions and enhancements of functions. Enhanced to allow the function to contain an external function interface. \begin{nonnormative} -Non-function specialized classes do not have this property. +Non-\lstinline!function! specialized classes do not have this property. \end{nonnormative} \item \lstinline!connector! -- diff --git a/chapters/equations.tex b/chapters/equations.tex index d000b8fe0..8669bcd20 100644 --- a/chapters/equations.tex +++ b/chapters/equations.tex @@ -630,8 +630,7 @@ \section{Events and Synchronization}\label{events-and-synchronization} used to guard against \emph{outside domain} errors, e.g.\ \lstinline!y = if noEvent(x>= 0) then sqrt(x) else 0.! \end{example} -All equations and assignment statements within when-clauses and all assignment statements within function classes are implicitly treated with \lstinline!noEvent!, i.e., relations within the scope of -these operators never induce state or time events. +All equations and assignment statements within when-clauses and all assignment statements within \lstinline!function! classes are implicitly treated with \lstinline!noEvent!, i.e., relations within the scope of these operators never induce state or time events. \begin{nonnormative} Using state events in when-clauses is unnecessary because the body of a when-clause is not evaluated during continuous integration. diff --git a/chapters/functions.tex b/chapters/functions.tex index c33174222..d03abdf53 100644 --- a/chapters/functions.tex +++ b/chapters/functions.tex @@ -113,7 +113,7 @@ \subsection{Inheritance of Functions}\label{inheritance-of-functions} following the usual rules for inheritance of classes (\cref{inheritance-modification-and-redeclaration}). \begin{nonnormative} -For example, it is possible to modify and extend a function class to add default values for input variables. +For example, it is possible to modify and extend a \lstinline!function! class to add default values for input variables. \end{nonnormative} \section{Function as a Specialized Class}\label{function-as-a-specialized-class} @@ -199,8 +199,7 @@ \section{Function as a Specialized Class}\label{function-as-a-specialized-class} \item Instances of functions have a special meaning, see \cref{functional-input-arguments-to-functions}. \item - The lookup of the function class to be called is extended, see - \cref{composite-name-lookup}. + The lookup of the \lstinline!function! class to be called is extended, see \cref{composite-name-lookup}. \end{itemize} \item A function can be \emph{recursive}. @@ -828,29 +827,20 @@ \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 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,...,argn)!, an application of the function -\lstinline!f! to the arguments \lstinline!arg1,..., argn! is defined. +Consider the expression \lstinline!f(arg1, $\ldots$, argn)!, an application of the function \lstinline!f! to the arguments \lstinline!arg1!, \ldots, \lstinline!argn! is defined. For each passed argument, the type of the argument is checked against the type of the corresponding formal parameter of the function. - \begin{enumerate} -\item +\item\label{argument-type-check-match} If the types match, nothing is done. \item If the types do not match, and a type conversion can be applied, it is - applied. Continue with step 1. + applied. Continue with step~\ref{argument-type-check-match}. \item - If the types do not match, and no type conversion is applicable, the - passed argument type is checked to see if it is an n-dimensional array - of the formal parameter type. If it is not, the function call is - invalid. If it is, we call this a foreach argument. + If the types do not match, and no type conversion is applicable, the passed argument type is checked to see if it is an $n$-dimensional array of the formal parameter type. If it is not, the function call is invalid. If it is, we call this a \emph{foreach argument}. \item For all foreach arguments, the number and sizes of dimensions must match. If they do not match, the function call is invalid. @@ -859,16 +849,12 @@ \subsection{Scalar Functions Applied to Array Arguments}\label{scalar-functions- fashion, and the result has the type specified by the function definition. \item - The result of the function call expression is an n-dimensional array - with the same dimension sizes as the foreach arguments. Each element - ei,..,j is the result of applying f to arguments constructed from the - original arguments in the following way: + The result of the function call expression is an $n$-dimensional array with the same dimension sizes as the foreach arguments. Each element \lstinline!ei!, \ldots, \lstinline!j! is the result of applying \lstinline!f! to arguments constructed from the original arguments in the following way: \begin{itemize} \item If the argument is not a foreach argument, it is used as-is. \item - If the argument is a foreach argument, the element at index - \lstinline![i, $\ldots$, j]! is used. + If the argument is a foreach argument, the element at index \lstinline![i, $\ldots$, j]! is used. \end{itemize} \end{enumerate} @@ -878,8 +864,8 @@ \subsection{Scalar Functions Applied to Array Arguments}\label{scalar-functions- \begin{example} \begin{lstlisting}[language=modelica] sin({a, b, c}) = {sin(a), sin(b), sin(c)} // argument is a vector -sin([a,b,c]) = [sin(a),sin(b),sin(c)] // argument may be a matrix -atan({a,b,c},{d,e,f}) = {atan(a,d), atan(b,e), atan(c,f)} +sin([a, b, c]) = [sin(a), sin(b), sin(c)] // argument may be a matrix +atan({a, b, c}, {d, e, f}) = {atan(a, d), atan(b, e), atan(c, f)} \end{lstlisting} This works even if the function is declared to take an array as one of its arguments. If \lstinline!pval! is defined as a function that takes diff --git a/chapters/interface.tex b/chapters/interface.tex index 02def7283..3f15a527a 100644 --- a/chapters/interface.tex +++ b/chapters/interface.tex @@ -536,9 +536,7 @@ \section{Function-Compatibility or Function-Subtyping for Functions}\label{funct \end{nonnormative} \begin{definition}[Function-compatibility or function-subtyping for functions] -A function class \lstinline!A! is \emph{function-compatible with or a function -subtype of} function class \lstinline!B! iff (the terms \emph{function-compatible} -and \emph{function subtype} of are synonyms and used interchangeably): +A \lstinline!function! class \lstinline!A! is \emph{function-compatible with or a function subtype of} \lstinline!function! class \lstinline!B! iff (the terms \emph{function-compatible} and \emph{function subtype} of are synonyms and used interchangeably): \begin{itemize} \item \lstinline!A! is compatible to (subtype of) \lstinline!B!. diff --git a/chapters/operatorsandexpressions.tex b/chapters/operatorsandexpressions.tex index baad2e3ba..304622356 100644 --- a/chapters/operatorsandexpressions.tex +++ b/chapters/operatorsandexpressions.tex @@ -1298,7 +1298,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op pre($y$) \end{lstlisting}\end{synopsis} \begin{semantics} -Returns the \emph{left limit} $y(t^{-})$ of variable $y(t)$ at a time instant $t$. At an event instant, $y(t^{-})$ is the value of $y$ after the last event iteration at time instant $t$ (see comment below). Any subscripts in the component expression $y$ must be parameter expressions. \lstinline!pre! can be applied if the following three conditions are fulfilled simultaneously: (a) variable $y$ is either a subtype of a simple type or is a record component, (b) $y$ is a discrete-time expression (c) the operator is \emph{not} applied in a function class. +Returns the \emph{left limit} $y(t^{-})$ of variable $y(t)$ at a time instant $t$. At an event instant, $y(t^{-})$ is the value of $y$ after the last event iteration at time instant $t$ (see comment below). Any subscripts in the component expression $y$ must be parameter expressions. \lstinline!pre! can be applied if the following three conditions are fulfilled simultaneously: (a) variable $y$ is either a subtype of a simple type or is a record component, (b) $y$ is a discrete-time expression (c) the operator is \emph{not} applied in a \lstinline!function! class. \begin{nonnormative} This can be applied to continuous-time variables in when-clauses, see \cref{discrete-time-expressions} for the definition of discrete-time expression. \end{nonnormative} @@ -1319,7 +1319,7 @@ \subsection{Event-Related Operators with Function Syntax}\label{event-related-op edge($b$) \end{lstlisting}\end{synopsis} \begin{semantics} -Expands into \lstinline!($b$ and not pre($b$))! for \lstinline!Boolean! variable $b$. The same restrictions as for \lstinline!pre! apply (e.g.\ not to be used in function classes). +Expands into \lstinline!($b$ and not pre($b$))! for \lstinline!Boolean! variable $b$. The same restrictions as for \lstinline!pre! apply (e.g.\ not to be used in \lstinline!function! classes). \end{semantics} \end{operatordefinition} @@ -1424,7 +1424,7 @@ \subsection{Parameter Expressions}\label{parameter-expressions} \item \lstinline!cardinality(c)!, see restrictions for use in \cref{cardinality-deprecated}. \item - \lstinline!end! in \lstinline!A[$\ldots$ end $\ldots$]! if \lstinline!A! is variable declared in a non-function class. + \lstinline!end! in \lstinline!A[$\ldots$ end $\ldots$]! if \lstinline!A! is variable declared in a non-\lstinline!function! class. \item \lstinline!size(A)! (including \lstinline!size(A, j)! where \lstinline!j! is parameter expression) if \lstinline!A! is variable declared in a non-function class. \item