Skip to content

Commit 8a5d6ef

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

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

chapters/functions.tex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,11 +290,13 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions}
290290
Binding equations for external objects.
291291
\end{itemize}
292292

293+
An exception is made for \lstinline!Modelica.Utilities.Streams.print!, for which none of the impure function restrictions apply.
294+
293295
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.
294296
The reason is that solving systems of equations generally requires expressions to be evaluated an unknown number of times.
295297
This includes the special handling of \lstinline!when initial()! during initialization.
296298

297-
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.
299+
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!.
298300
The side-effect semantics of the function call are then undefined.
299301
Specifically, the number of calls with external side-effects is unspecified.
300302
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)