Opened 8 years ago

Closed 8 years ago

#4383 closed defect (invalid)

Array constructor { } fails

Reported by: jens.schoenbohm@… 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)

comment:1 by Martin Sjölund, 8 years ago

MetaModelica doesn't allow using Modelica-style arrays.

in reply to:  1 ; comment:2 by Lennart Ochel, 8 years ago

Replying to sjoelund.se:

MetaModelica doesn't allow using Modelica-style arrays.

Is there any good reason for this restriction?

in reply to:  2 comment:3 by Martin Sjölund, 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 Lennart Ochel, 8 years ago

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.