Opened 10 years ago

Closed 10 years ago

#2873 closed enhancement (fixed)

Implement for-loop for arrays

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: high Milestone: Bootstrapping
Component: MetaModelica Version: trunk
Keywords: Cc:

Description (last modified by Per Östlund)

It would be nice to be able to loop over arrays in the bootstrapped compiler, similar to how it's possible to loop over lists. E.g.:

  array<T> someArray;
algorithm
  for e in someArray loop
    // Some code
  end for;

Change History (5)

comment:1 by Per Östlund, 10 years ago

Description: modified (diff)
Summary: Implemented for-loop for arraysImplement for-loop for arrays

comment:2 by Adrian Pop, 10 years ago

Also would be nice to have pattern matching on the array elements, not the entire array, i.e.

case (a[1] as "blah") then something;

in reply to:  2 comment:3 by Martin Sjölund, 10 years ago

Replying to adrpo:

case (a[1] as "blah") then something;

Looks very bad. I read this as

match str
  case "blah"
    algorithm
      a[1] := "blah";
    then something;

comment:4 by Per Östlund, 10 years ago

This is possible though:

_ := match(a[1])
  case "blah" then something;
end match;

comment:5 by Martin Sjölund, 10 years ago

Resolution: fixed
Status: newclosed

Fixed in r22702 (none of the pattern-matching on array elements as it should not be needed in the bootstrapped compiler).

Note: See TracTickets for help on using tickets.