Opened 10 years ago

Closed 10 years ago

#2887 closed enhancement (fixed)

Implement construct similar to try/catch

Reported by: Per Östlund Owned by: Martin Sjölund
Priority: normal Milestone: 1.9.1
Component: MetaModelica Version: trunk
Keywords: Cc: openmodelicadevelopers@…

Description

I currently find myself writing code like this fairly often:

algorithm
  _ := matchcontinue()
    case ()
      equation
        // Do something which might fail.
      then
        ();
    
    else
      equation
        // Do something else.
      then
        ();
  end matchcontinue;

It would be nice to have some syntactic sugar for this kind of construct, something like:

algorithm
  try
    // Do something which might fail.
  else
    // Do something else.
  end try;

One issue with translating this into a match-statement is that you have to use equations instead of algorithms inside the try-statement though.

Change History (2)

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

Cc: openmodelicadevelopers@… added

Does any of the developers have any feedback on the proposed try statement? The implementation issues mentioned above are not an issue since I will implement #2886 at the same time.

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

Milestone: Bootstrapping1.9.1
Resolution: fixed
Status: newclosed

Fixed in r22755.

Note: See TracTickets for help on using tickets.