You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If a function is declared as \lstinline!impure! any function extending from it shall be declared as \lstinline!impure!.
233
233
\item
234
234
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.
236
236
\end{itemize}
237
237
238
238
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.
An exception is made for \lstinline!Modelica.Utilities.Streams.print!, for which none of the impure function restrictions apply.
283
+
282
284
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.
283
285
The reason is that solving systems of equations generally requires expressions to be evaluated an unknown number of times.
284
286
This includes the special handling of \lstinline!when initial()! during initialization.
285
287
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!.
287
289
The side-effect semantics of the function call are then undefined.
288
290
Specifically, the number of calls with external side-effects is unspecified.
289
291
However, for impure functions where the outputs only depend on the inputs the system of equations should be solved correctly.
0 commit comments