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
There are some pure MSL 4.0.0 functions, which call other (impure) MSL functions, which is not allowed according to Modelica specification section 12.3.
I found the issues #3857, #3856, #3855 , and #3655, which are all still open.
Since from our perspective more tools are checking this now, the number of warnings thrown during simulation increased. Is there something planned regarding those issues?
Expected behaviour
Impure functions are only called in the circumstances allowed by the Modelica specification section 12.3.
Is there something planned regarding this problem here.
It still exists with MSL 4.1.0. For example the pure function Modelica.Utilities.Files.loadResource calls the impure function Modelica.Utilities.Files.fullPathName.
It seems that the Modelica specification will be reworked regarding impure and pure as well (see modelica/ModelicaSpecification#3719).
But is there something planned for the MSL independent from eventual changes in the specification. @HansOlsson do you maybe have something to add here?
To explain our pain with this problem. We are automatically checking (check function of the tools) all of our models within our CI pipelines. If there is a warning within the MSL, all of our models using that Modelica function will fail their CI test and we have to program an exception for the specific warning message.
Is there something planned regarding this problem here. It still exists with MSL 4.1.0. For example the pure function Modelica.Utilities.Files.loadResource calls the impure function Modelica.Utilities.Files.fullPathName.
That specific example is even messier than many others:
The function Modelica.Utilities.Files.fullPathName is one of the special cases of impure functions that only depend on the external environment, but don't change it.
The call of Modelica.Utilities.Files.fullPathName is in the default implementation of Modelica.Utilities.Files.loadResource - but the implementation in many tools differ. In Dymola the called function is declared without any prefix. However, based on what loadResource is supposed to do I believe it should be impure. To enforce that it makes sense that its base-class Modelica.Utilities.Internal.PartialModelicaServices.ExternalReferences.PartialLoadResource should also be impure.
It seems that the Modelica specification will be reworked regarding impure and pure as well (see modelica/ModelicaSpecification#3719). But is there something planned for the MSL independent from eventual changes in the specification. @HansOlsson do you maybe have something to add here?
#4686 (and also #4685 to avoid the problems with print)
Thanks for the detailed explanation. I have to admit that I am not to deep into this topic and have not fully understood everything from the linked issues.
We are happy that work is being spent on improving the whole impure/pure situation since our main objective with this is that no warnings from within the MSL are thrown when we simulate our models.
Activity
[-]Pure function calling impure functions [/-][+]Pure functions calling impure functions [/+]abuntrock commentedon Aug 20, 2025
Is there something planned regarding this problem here.
It still exists with MSL 4.1.0. For example the pure function
Modelica.Utilities.Files.loadResourcecalls the impure functionModelica.Utilities.Files.fullPathName.It seems that the Modelica specification will be reworked regarding impure and pure as well (see modelica/ModelicaSpecification#3719).
But is there something planned for the MSL independent from eventual changes in the specification. @HansOlsson do you maybe have something to add here?
To explain our pain with this problem. We are automatically checking (check function of the tools) all of our models within our CI pipelines. If there is a warning within the MSL, all of our models using that Modelica function will fail their CI test and we have to program an exception for the specific warning message.
HansOlsson commentedon Aug 20, 2025
That specific example is even messier than many others:
Modelica.Utilities.Files.fullPathNameis one of the special cases of impure functions that only depend on the external environment, but don't change it.Modelica.Utilities.Files.fullPathNameis in the default implementation ofModelica.Utilities.Files.loadResource- but the implementation in many tools differ. In Dymola the called function is declared without any prefix. However, based on what loadResource is supposed to do I believe it should be impure. To enforce that it makes sense that its base-classModelica.Utilities.Internal.PartialModelicaServices.ExternalReferences.PartialLoadResourceshould also be impure.#4686 (and also #4685 to avoid the problems with print)
HansOlsson commentedon Aug 20, 2025
A minor clarification of my previous comment:
abuntrock commentedon Aug 21, 2025
Thanks for the detailed explanation. I have to admit that I am not to deep into this topic and have not fully understood everything from the linked issues.
We are happy that work is being spent on improving the whole impure/pure situation since our main objective with this is that no warnings from within the MSL are thrown when we simulate our models.