Update purity exception for Streams.print#3706
Update purity exception for Streams.print#3706henrikt-ma wants to merge 1 commit intomodelica:masterfrom
Conversation
I agree that the current status is not good, but as far as I understand this change mean that we have a permanent exception for I think we need to analyze it in more detail:
Looking at MSL I see some of the problems, and also that some of uses of print should likely be replaced by assert-warnings. |
|
I investigated MSL regarding this. This first lead to the proposed changes:
And also the conclusion:
I thus believe we should revisit Specifically we have the issue that if one decides to declare an external function as That downstream change will be a problem for any library developer, and we didn't even do it correctly for MSL. That means that the simplest solution for users is to not declare an external function as I believe the best way forward is to change so that functions defined in Modelica without pure/impure that directly or indirectly call an external function declared as impure will be assumed to be impure. (But without allowing them to be called everywhere.) |
HansOlsson
left a comment
There was a problem hiding this comment.
I agree that the current situation isn't good.
But I don't think we should to keep the exception for print.
However, I also think that we need to revisit the impure handling, and will open a new issue.
|
Based on #3755 I would say that we can just remove all exceptions for print, which would simplify this PR. |
Reformulating to match the current MSL where 'print' is declared impure.
8e08ea6 to
8a5d6ef
Compare
(Not only simplify; there would be nothing left.) Do you mean that the non-deprecated way of adding debug prints to a pure function is to do |
|
Language group: No exception for print. |
|
Now that it was decided to not make any exception for |
In https://specification.modelica.org/master/functions.html#pure-modelica-functions there is the following exception for
print:The problem is that
Modelica.Utilities.Streams.printis nowadays explicitly markedimpure, so the exception is only causing confusion at the moment.This PR updates the specification so that it applies to the current MSL. The most important part, that there is a loophole for calling
printanywhere, still applies to older MSL whereprintis not explicitly declaredimpure. The only change for older MSL is that the deprecated semantics demands a diagnostic in this case – I find it better that tools act on their own on this matter than to elaborate the rules for diagnostics in the specification.