diff --git a/chapters/functions.tex b/chapters/functions.tex index 87bf5a57b..16e587d09 100644 --- a/chapters/functions.tex +++ b/chapters/functions.tex @@ -284,6 +284,12 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions} The reason is that solving systems of equations generally requires expressions to be evaluated an unknown number of times. This includes the special handling of \lstinline!when initial()! during initialization. +There are two ways in which an impure function could be called in a system of equations, +namely in the deprecated case of external functions assumed to be impure, and when using \lstinline!pure($\ldots$)! to call an impure function from within a pure function. +The side-effect semantics are undefined in this case. +Specifically the number of calls with external side-effects is unspecified. +However, for impure functions where the outputs only depend on the inputs the system of equations should be solved correctly. + \begin{nonnormative} A tool is not allowed to perform any optimizations on function calls to an impure function, e.g., reordering calls from different @@ -294,11 +300,6 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions} By \cref{function-compatibility-or-function-subtyping-for-functions}, it follows that an impure function can only be passed as argument to a function formal parameter of impure type. A function having a formal function parameter that is \lstinline!impure! must be marked \lstinline!pure! or \lstinline!impure!. -\begin{nonnormative} -Comment: The semantics are undefined if the function call of an -impure function is part of an algebraic loop. -\end{nonnormative} - \begin{example} \begin{lstlisting}[language=modelica] function evaluateLinear // pure function