4 ms·
How would you write this without exception handling, how would that make it any easier? Perhaps do not put the entire loop in the try catch, but just the single
by btipling 14y ago
How would you write this without exception handling, how would that make it any easier? Perhaps do not put the entire loop in the try catch, but just the single iteration.
- reginaldo 14y agoOh no. I'm not saying it would be easier without exceptions. I'm just saying that the current status of our programming tools makes writing safe code very hard, and exceptions are one more thing you have to think about. I use them a lot... The authors of the paper propose their "worlds" API as a way to make writing safe code easier. They're still using exceptions, but they would require no cleanup... The code becomes: try { in thisWorld.sprout() { for (var idx = 0; idx < xs.length; idx++) xs[idx].update(); thisWorld.commit(); } } catch (e) { // no clean-up required! } So it's commit for data structures for data structures. If an exception is thrown and the commit line is not executed, no changes will be visible.
- deleted 14y ago[deleted]