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
Reported by petfr on 18 Aug 2013 10:23 UTC
A design goal and property in Modelica is that array
dimensions should be possible either on the type or
on the component, i.e., both of the following are allowed:
Real[20] vec;
Real vec[20];
This language rule is broken for modifiers in the current version
of Modelica, MS 3.2.2, where the form vec[20] is allowed
but not Real[20]. This inconsistenly just recently caused
me a lot of confusion. The language grammar should be updated
to consistenly allow both forms.
Current grammar:
element_replaceable:
replaceable ( short_class_definition | component_clause1) [constraining_clause]
Comment by hansolsson on 24 Sep 2013 08:27 UTC
Language group:
Consider:
type Vec=Real[:];
type Vec2=Real[2];
class C3
Real x1;
Vec x2[:];
Vec [:] x3[:];
end C3;
Currently C3(redeclare Vec2 x2); means keep : from original declaration, i.e. Vec2 x2[:] and C3(redeclare Real x2[3,2]); is not allowed, since the "type" should have same dimensions as original declaration (end of section 7.3.2).
And C3(redeclare Vec x3[2]); is not allowed; i.e. the type-dimensions are not allowed to be "inherited" independently (end of 7.3.2). Either give all array dimensions or none.
So view Real[4] x[2] as syntactic sugar for Real x[2,4];; and either give all array dimensions or none; and thus logical to allow that in redeclare as well.
Conclusion: State that just syntactic sugar and allow in redeclare as well.
Agreement.
Poll: Include in 3.3r1?
Agree: 0
Against: 1
Abstain: 5
Conclusion: needs more work.
Comment by hansolsson on 1 Mar 2017 14:11 UTC
In 7.3 state that:
Replaceable component array declarations with array sizes on the left of the component are seen as syntactic sugar for having all arrays sizes on the right of the component; and thus can be redeclared in a consistent way.
Example:
model M
replaceable Real [4] x[2];
end M;
M m(redeclare Modelica.SIunits.Length x[2,4]);
Reported by petfr on 18 Aug 2013 10:23 UTC
A design goal and property in Modelica is that array
dimensions should be possible either on the type or
on the component, i.e., both of the following are allowed:
Real[20] vec;
Real vec[20];
This language rule is broken for modifiers in the current version
of Modelica, MS 3.2.2, where the form vec[20] is allowed
but not Real[20]. This inconsistenly just recently caused
me a lot of confusion. The language grammar should be updated
to consistenly allow both forms.
Current grammar:
element_replaceable:
replaceable ( short_class_definition | component_clause1) [constraining_clause]
component_clause1:
type_prefix type_specifier component_declaration1
type_prefix: flow | stream | ...
type_specifier: name
component_declaration1: declaration comment
declaration: IDENT [ array_subscripts ] [ modification ]
Example which is accepted by current grammar and by Dymola:
package testredeclare
class C3
Real x1;
Real[:] vec;
end C3;
class C4 = C3(redeclare parameter Real x1, redeclare Real vec[20]);
end testredeclare;
Example which is not accepted by current grammar:
package testredeclare
class C3
Real x1;
Real[:] vec;
end C3;
class C4 = C3(redeclare parameter Real x1, redeclare Real[20] vec);
end testredeclare;
Migrated-From: https://trac.modelica.org/Modelica/ticket/1251
The text was updated successfully, but these errors were encountered: