-
Notifications
You must be signed in to change notification settings - Fork 44
Description
Looking at MSL 4.1.0 due to #3706 I realized that we didn't get impure right in the library, and the current semantics problematic (unless you use a rather odd interpretation).
With the current rules if you don't add pure/impure everywhere it just works (with diagnostics), and external functions are kind of assumed to be impure.
The problem is then that you try to be good and add impure
to the external calls. The intent is then that callers should be declared as impure
(etc), which clearly would be good. However, we failed to do that in MSL as corrected by modelica/ModelicaStandardLibrary#4686 - and to me it doesn't make sense that trying to be good by adding impure turn a diagnostics for deprecated behavior into an error.
The likely consequence is that people will be reluctant to add impure
to external functions, since there will be too much down-stream work and/or complaints, or that tools will not implement the semantics (arguing that the proposed behavior is the "correct interpretation").
Currently it says:
A deprecated semantics is that external functions (and functions defined in Modelica directly or indirectly calling them) without pure or impure keyword are assumed to be impure, but without any restriction on calling them.
My first proposal is something along the lines for:
A deprecated semantics for functions without pure or impure is that they 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 pure keyword) calling external functions without pure keyword.
And remove the "However, since functions as default are pure it is not recommended to explicitly declare them as pure".
The second proposal would be to more completely revisit pure/impure.