Opened 10 years ago

Closed 10 years ago

#2887 closed enhancement (fixed)

Implement construct similar to try/catch

Reported by: perost Owned by: sjoelund.se
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 Changed 10 years ago by sjoelund.se

  • 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 Changed 10 years ago by sjoelund.se

  • Milestone changed from Bootstrapping to 1.9.1
  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r22755.

Note: See TracTickets for help on using tickets.