5 ms·
try/catch seems very conditional to me. If there is an error condition, jump to the error handling code. Or am I missing something?
by Akronymus 3y ago
try/catch seems very conditional to me. If there is an error condition, jump to the error handling code. Or am I missing something?
- PH95VuimJjqBqy 3y agoI could also describe a JMP instruction as "if you got here, jump to there", but just because I can doesn't necessarily mean I should.
- epcoa 3y agoBut Try, catch and throw are in themselves not conditional, they are fancy gotos with bookkeeping. Those constructs don’t typically deal with conditions. However I think the notion that “flow control” has to do only with conditionals is not a common one. FWIW the definition on Wikipedia, which aligns with my experience is not this restrictive… the lowly goto is flow control. Basically anything that controls the program location is flow control.
- Akronymus 3y agoYeah, but raising the error is the conditional in there. Which, to me, makes the try catch conditional as well, but that may be a case of differing semantics. Yeah, flow control isn't just conditional jumps. You can kinda treat branchless code as a form of flow control as well.
- PH95VuimJjqBqy 3y ago> You can kinda treat branchless code as a form of flow control as well. That's the common understanding of flow control, the other poster is right in that it's not typically just conditionals. There are a few posters who were under that misapprehension, but that's never been the common understanding of it, it's just that conditionals are typically where people worry over flow control because otherwise it's linear.