Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
ghaberek said...
Spock said...

Ok. I think I got this right:

1 Add delete_routine() to libraries - cleanup happens automatically when atom leaves scope
Or
2 Use try/catch/finally - manually call cleanup routine

Let's say I'm too lazy to do 1 (or it'd be really awkward since my libraries usually return integers (object IDs) not pointers). So how will I know which cleanup routines to call in finally in 2?

Spock

That's entirely up to you, isn't it? You'd have to clean up whatever you started, correct?

The finally statement simply affords you that opportunity, and it is entirely optional.

Hi Greg,

Thanks for the code example. An important difference between the 2 systems is that the low-level clean up in SSC must always occur since execution is never interrupted - the routine simply completes and returns as normal. So at the top level the "clean up" is of a different kind as the problem now is overshoot rather than premature termination. The top level would be more like:

 
   ERRNO = 0 
 
   integer x = getThing() 
 
   step_1( x ) 
   step_2( x ) 
   step_3( x ) 
   step_4( x ) 
   step_5( x ) 
 
   if ERRNO = REALLYBADERROR then 
      undo( x ) 
      return 
   end if 
 

But like I said to Pete, the point is largely moot anyway as try/catch is going to eventually be added to OE.

Spock

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu