Re: Try/Catch

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

If the error code is ORed instead of MOVed then explicit handling is not required at each step. It will simply "bubble up" until it encounters a test written for it. Whole levels could be written without any error checking but the error code will still happily pass through.

What I'm not seeing in your proposal is how it offers something better than try/catch.

If I understand, you are proposing that instead of RTFatal halting Euphoria (as it does now), you're suggesting that some sort of default behavior be taken. For example, this currently throws an exception:

atom a = 1 / 0 -- throws an exception 
? a -- never gets executed 

Instead, (if I understand this) you're suggesting that some sensible behavior be defined instead of halting, and err, errno and errno-flag be set.

For example, division by zero could by default return undefined.

atom a = 1 / 0 -- sets a to undefined, and sets err, errno and errno-flag 
? a -- executes, but a is undefined. possibly sets another errno and errno-flag 

This could result in a cascade of errors, which is why errno-flag has to be ANDed together to determine which bit is set.

In the meantime, the code continues to execute normally, until the result of err is checked.

Is this correct?

- David

More or less, yes. Some calls will force the user to check errno immediately afterwards. The program could return at that point or handle the error then and there (or somewhere else in that routine). Errors from other calls won't immediately affect the program operation.

A cascade of errors is unlikely or would be very limited. In any case, an error log recording each error is kept for later study so we don't accidentally overwrite a previous error.

SSC might not be "better" than try/catch but is it materially worse? In some ways it might be simpler to implement.

Spock

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

Search



Quick Links

User menu

Not signed in.

Misc Menu