ModelicaStandardLibrary icon indicating copy to clipboard operation
ModelicaStandardLibrary copied to clipboard

Declare parameter records as replaceable?

Open AHaumer opened this issue 3 years ago • 0 comments

Recently I had a discussion with @casella and @perost about parameter records, as used in Modelica.Magnetic.FluxTubes.

As today, the parameter record is instantiated as

  parameter FluxTubes.Material.SoftMagnetic.BaseData material=Material.SoftMagnetic.BaseData()
    annotation (choicesAllMatching=true);

A tool is free to extend the standard and present a drop-down menu, modifying the parameter material with a record constructor component(material=Modelica.Magnetic.FluxTubes.Material.SoftMagnetic.ElectricSheet.M350_50A())

As @casella pointed out, the specification is very clear:

Only classes and components declared as replaceable can be redeclared with a new type, which must have an interface compatible with the constraining interface of the original declaration, and to allow further redeclarations one must use redeclare replaceable.

As @perost pointed out, the specification currently only specifies the use of choicesAllMatching on replaceable elements,

So the point is: Either should the specification get extended to use choicesAllMatching for modifying parameters, too, or we should use in MSL the following instantiation:

  replaceable parameter FluxTubes.Material.SoftMagnetic.BaseData material=Material.SoftMagnetic.BaseData()
    annotation (choicesAllMatching=true);

causing the tool to use a redeclaration: component(redeclare Modelica.Magnetic.FluxTubes.Material.SoftMagnetic.ElectricSheet.M350_50A material);

Different tools should offer the same behaviour for MSL models. What's your opinion? I suppose the issue should get discussed in MAP-Lang and MAP-Lib.

AHaumer avatar Jun 25 '22 07:06 AHaumer