Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify impure in systems of equations. #3571

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions chapters/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,14 @@ \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.

\begin{nonnormative}
HansOlsson marked this conversation as resolved.
Show resolved Hide resolved
It is still possible to call an impure function in a system of equations in specific ways.
Specifically for the deprecated case of external functions assumed to be impure, and when using \lstinline!pure(expression)! to call an impure function in a pure function.
HansOlsson marked this conversation as resolved.
Show resolved Hide resolved
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.
\end{nonnormative}
HansOlsson marked this conversation as resolved.
Show resolved Hide resolved

\begin{nonnormative}
A tool is not allowed to perform any optimizations on function
calls to an impure function, e.g., reordering calls from different
Expand All @@ -294,11 +302,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
Expand Down