Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
DerekParnell said...
dcuny said...

I'm wondering how try/catch/finally might be implemented in Euphoria.

Setting aside, for the moment, the examination of any compelling reasons to implement this concept into the language, I suggest a much more simpler approach - maybe a more Euphoric approach I think.

The concept is sound and it'd be easier to implement. What's not to like?

DerekParnell said...

Control does not return to the application.

The issue here would be, in dcuny's original example, that there is still no way to handle 'x = s[i]' effectively without having the program (eventually) crash. This is still an improvement (as least you have a last-ditch chance to save any unsaved data), but you can't deal with unexpected exceptions and pick off from where you left off. Maybe that's a good thing.

Still, I don't think it'd be technically hard to make it so that, if all trap handlers return the OK result, to return control to the following statement or something... maybe one could specify a goto label along with the trap handler routine id, that would only be used if the trap was triggered within scope of that label. So, we can make this more flexible. (Not saying that we should, necessarily, just that we can if it is decided that that would be the way to go.)

DerekParnell said...
  • Make RTFatal() callable from user written code. This effectively implements the 'throw' concept.

We already have crash() for that. Or do you mean a resume_trapped_ex() which could only be called from inside the trap handler?

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

Search



Quick Links

User menu

Not signed in.

Misc Menu