modelica / ModelicaSpecification

Specification of the Modelica Language
https://specification.modelica.org
Creative Commons Attribution Share Alike 4.0 International
103 stars 41 forks source link

Variability of external object construction #2661

Open henrikt-ma opened 4 years ago

henrikt-ma commented 4 years ago

It seems strange that an external object constructor is allowed to be called with non-parameter arguments, considering that the function call won't be evaluated again after initialization.

Ways of addressing this include:

HansOlsson commented 4 years ago

Note that MSL has external object declared with parameter-variability following https://github.com/modelica/ModelicaStandardLibrary/commit/48af06d62a2c0068d6407cdb2db2791e646f42ef That ensures that the external object constructor is only called with parameter-arguments.

henrikt-ma commented 4 years ago

Note that MSL has external object declared with parameter-variability following modelica/ModelicaStandardLibrary@48af06d That ensures that the external object constructor is only called with parameter-arguments.

That sounds like they've done a workaround (safeguard) for a potential pitfall in the specification.

HansOlsson commented 3 years ago

Note that MSL has external object declared with parameter-variability following modelica/ModelicaStandardLibrary@48af06d That ensures that the external object constructor is only called with parameter-arguments.

That sounds like they've done a workaround (safeguard) for a potential pitfall in the specification.

Note that additionally the table doesn't change during the simulation.

There can also be external-objects that you "write" to - in which case declaring them as "parameter" doesn't seem right.

Considering such external objects I would say that it is natural that the constructor is part of the initial section, but not that the argument must be parameters (as you can anyway change the external object later).

henrikt-ma commented 3 years ago

Maybe it's best to postpone this issue while waiting for the resolution of #2602?