Skip to content
Open
Changes from all 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
11 changes: 4 additions & 7 deletions chapters/functions.tex
Original file line number Diff line number Diff line change
Expand Up @@ -225,16 +225,13 @@ \section{Pure Modelica Functions}\label{pure-modelica-functions}
\item
Functions defined in Modelica (non-external) are \emph{normally} assumed to be pure (the exception is the deprecated case below), if they are impure they shall be marked with the \lstinline!impure! keyword.
They can be explicitly marked as \lstinline!pure!\indexinline{pure}.
\begin{nonnormative}
However, since functions as default are pure it is not recommended to explicitly declare them as \lstinline!pure!.
\end{nonnormative}
\item
External functions must be explicitly declared with \lstinline!pure! or \lstinline!impure!.
\item
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.
Except for the function \lstinline!Modelica.Utilities.Streams.print!, a diagnostic must be given if called in a simulation model.
External functions should be explicitly declared with \lstinline!pure! or \lstinline!impure!.
The case without the keyword is deprecated semantics described in the next item.
Comment on lines +231 to +232
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw your comment, but I don't agree that this is the style in which the specification is written. I believe this is how we do it:

Suggested change
External functions should be explicitly declared with \lstinline!pure! or \lstinline!impure!.
The case without the keyword is deprecated semantics described in the next item.
External functions shall be explicitly declared with \lstinline!pure! or \lstinline!impure!.
A deprecated semantics is that an external function declared with neither \lstinline!pure! nor \lstinline!impure! is handled according to the next item.

Copy link
Collaborator Author

@HansOlsson HansOlsson Oct 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The usual specification define of shall/should is rfc2119 - and deprecated mean discouraged, not forbidden.
Combined I don't see that one can combine "shall" and deprecated in that way.

Modelica Specification could be different, but I could not find any such uses of deprecated combined with shall/should/must/may but instead found:

\item
A deprecated semantics for functions without \lstinline!pure! or \lstinline!impure! keyword is that they are assumed to be impure, but without any restriction on calling them for the following cases: external functions and functions defined in Modelica directly or indirectly (through functions without the \lstinline!pure! keyword) calling external functions without \lstinline!pure! keyword.
\end{itemize}

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.
Expand Down