Opened 8 years ago
Closed 8 years ago
#4383 closed defect (invalid)
Array constructor { } fails
Reported by: | Owned by: | Martin Sjölund | |
---|---|---|---|
Priority: | normal | Milestone: | |
Component: | MetaModelica | Version: | |
Keywords: | array constructor | Cc: |
Description
Array construction with { } and constants fail. If I use { } and expressions everything is ok. See example
function main protected Real m[:]; Real b[:]; algorithm m := {1.0,2.0,3.0,4.0}; // Error: Type mismatch in assignment in m := List(#(1.0), #(2.0), #(3.0), #(4.0)) of Real[:] := list<#Real> b := {r for in 1.0:4.0}; // OK end main;
Change History (4)
follow-up: 2 comment:1 by , 8 years ago
follow-up: 3 comment:2 by , 8 years ago
Replying to sjoelund.se:
MetaModelica doesn't allow using Modelica-style arrays.
Is there any good reason for this restriction?
comment:3 by , 8 years ago
Replying to lochel:
Replying to sjoelund.se:
MetaModelica doesn't allow using Modelica-style arrays.
Is there any good reason for this restriction?
Yes. It doesn't work very well to mix them. Modelica arrays are not boxed, sometimes stack-allocated, is mutable, and horrible with function pointers. So with -d=rml
, {}
becomes a list and you basically cannot use arrays.
Also remember, RML syntax for array<Real>
was equivalent to Real[:]
, but they are totally different in OMC.
comment:4 by , 8 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
MetaModelica doesn't allow using Modelica-style arrays.