Skip to content

Commit 8e08ea6

Browse files
committed
Update purity exception for Streams.print
Reformulating to match the current MSL where 'print' is declared impure.
1 parent 09bdd63 commit 8e08ea6

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

chapters/functions.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions}
232232
If a function is declared as \lstinline!impure! any function extending from it shall be declared as \lstinline!impure!.
233233
\item
234234
A deprecated semantics is that external functions (and functions defined in Modelica directly or indirectly calling them) without \lstinline!pure! or \lstinline!impure! keyword are assumed to be impure, but without any restriction on calling them.
235-
Except for the function \lstinline!Modelica.Utilities.Streams.print!, a diagnostic must be given if called in a simulation model.
235+
A diagnostic must be given if called in a simulation model.
236236
\end{itemize}
237237

238238
Calls of pure functions used inside expression may be skipped if the resulting expression will not depend on the possible returned value; ignoring the possibility of the function generating an error.
@@ -279,11 +279,13 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions}
279279
Binding equations for external objects.
280280
\end{itemize}
281281

282+
An exception is made for \lstinline!Modelica.Utilities.Streams.print!, for which none of the impure function restrictions apply.
283+
282284
It is an error if an impure function call is part of a systems of equations (including linear systems), even if called in agreement with the restrictions above.
283285
The reason is that solving systems of equations generally requires expressions to be evaluated an unknown number of times.
284286
This includes the special handling of \lstinline!when initial()! during initialization.
285287

286-
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.
288+
There are three 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, when using \lstinline!pure($\ldots$)! to call an impure function from within a pure function, and the exception for \lstinline!Modelica.Utilities.Streams.print!.
287289
The side-effect semantics of the function call are then undefined.
288290
Specifically, the number of calls with external side-effects is unspecified.
289291
However, for impure functions where the outputs only depend on the inputs the system of equations should be solved correctly.

0 commit comments

Comments
 (0)