-
Notifications
You must be signed in to change notification settings - Fork 41
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
base: master
Are you sure you want to change the base?
Changes from 2 commits
d1ffdc4
7b3ed76
8373b96
360e96d
f9338b8
467e876
cd720e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -232,6 +232,7 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions} | |||||||||||||
If a function is declared as \lstinline!impure! any function extending from it shall be declared as \lstinline!impure!. | ||||||||||||||
\item | ||||||||||||||
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. | ||||||||||||||
Similarly they can be part of systems of equations without restrictions. | ||||||||||||||
Except for the function \lstinline!Modelica.Utilities.Streams.print!, a diagnostic must be given if called in a simulation model. | ||||||||||||||
\end{itemize} | ||||||||||||||
|
||||||||||||||
|
@@ -295,8 +296,8 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions} | |||||||||||||
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. | ||||||||||||||
Comment: The semantics are undefined if the function call of an impure function is part of an algebraic loop. | ||||||||||||||
HansOlsson marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||||||||
This can occur for the deprecated case of external functions assumed to be impure, or when using \lstinline!pure(expression)! to call an impure function in a pure function. | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I believe this was the intended idea. Not a general undefined-behavior in C-terms (with nasal demons etc), but just the pragmatic point that you cannot solve an algebraic loop with an impure function that e.g., returns the current time in nano-seconds, and that you have no control of the number of external side-effects generated. That's why it is non-normative. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about speaking of side-effect semantics? Wouldn't that then be nicely elaborated by the outputs-only-depending-on-inputs rule? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, makes sense. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Have now done that. |
||||||||||||||
\end{nonnormative} | ||||||||||||||
|
||||||||||||||
\begin{example} | ||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we manage to write the text clearly, there shouldn't be a need for this sentence, as the systems-of-equations rule should be perceived as one of the calling restrictions.