3 ms·
>> However, the reading is larger than the biggest possible 16 bit integer, a conversion is tried and fails. Usually, a well-designed system would have a proced
by phkahler 4y ago
>> However, the reading is larger than the biggest possible 16 bit integer, a conversion is tried and fails. Usually, a well-designed system would have a procedure built-in to handle an overflow error and send a sensible message to the main computer. This, however, wasn’t one of those cases.
This is so unbelievably untrue. I've never seen code anywhere that waits to fail before doing the right thing.
This is exactly why I think exceptions are mostly useless, someone has to anticipate the problem, so why not write something that works right the first time. There are cases where exceptions can happen, but I don't think floating point arithmetic should be considered one of those cases.
- testrun 4y ago>>so why not write something that works right the first time Nobody writes 100% correct code. Ever.
- rvnx 4y ago"Remote computer is not answering" What is the correct code then ? In case there is no exception.
- WalterBright 4y agoSpeak for yourself.
- M4R5H4LL 4y agoThat's an untested assumption :)
- RantyDave 4y agoThey might do, we should test for that. These stories of gnat-brings-down-empire are, to me, always missing the point. There are going to be bugs. The hard part is in creating management around the actual software engineering such that this is not a problem.
- phkahler 4y agoThat's right. But nobody puts their best code in a generic exception handler either.
- zaroth 4y ago“Exceptions” are just a name we give to a particular type of flow control and syntactic sugar. In this case the syntactic sugar helps deal with passing data across function boundaries and up the stack in a way that can make the code more readable. Every function could handle returning its own error states, and then higher level functions could aggregate and check and return the error states of every function it calls… or you might find it saves a massive amount of boilerplate to just use try/catch!