Re: Try/Catch

new topic     » goto parent     » topic index » view thread      » older message » newer message
Spock said...
sequence s = "" 
object x = s[1] -- no crash 
? x -- {} 
? ERRNO -- BAD_INDEX 

This is equivalent to ON ERROR CONTINUE in Basic.

Once Euphoria has identified an exception has taken place, continuing on as if no exception took place is the incorrect behavior.

Returning some default value (zero, null, whatever) is obviously wrong, because ultimately you're going to have to discard that value.

Spock said...

However, I think bad indexes are a poor example (in the context of the topic) since they are programming errors that must be corrected rather than somehow "managed". Certainly, in program development a bad index should cause a crash so I can fix the problem. For program deployment the behaviour will revert to above (with signalling).

That would be fine, except that Euphoria defines these as exceptions.

If you want to argue that it shouldn't do that, fine - but that's a different conversation.

And because Euphoria defines these as exceptions, they aren't poor examples - they are exactly what we're talking about.

I've asked this several times, but not yet gotten an answer: have you ever used try/catch? Based on the objections you continue to raise, I can only assume that you haven't.

- David

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

Search



Quick Links

User menu

Not signed in.

Misc Menu