3 ms·
You need C++'s RAII idiom or go's defer syntax to get the same behaviour though. I think try-with-resource in Java also would do the same thing, maybe. Just pla
by anonymous 13y ago
You need C++'s RAII idiom or go's defer syntax to get the same behaviour though. I think try-with-resource in Java also would do the same thing, maybe. Just plainly throwing an exception won't release what you've acquired.
- qznc 13y agoSomething like go's defer makes most uses of goto (failure handling) unnecessary. However, there is still the "code a state machine" use case for goto.
- loumf 13y agoWhich we are trying to eliminate with tail-call-optimized mutually recursive functions.
- klodolph 13y agoWhich are semantically less clear than goto, when you are working with something that is semantically a state machine.
- dragonwriter 13y agoActually, I think that mutually-recursive functions are more semantically clear than goto for a state machine, though using explicit state objects is even more clear than either (though probably less efficient.)
- stcredzero 13y agoensure: blocks were how it was done in Smalltalk. You simply had a block of code that was followed by another block of code that the system would ensure the execution of. There was slightly more to it. You had to make sure that whatever ran in that block wouldn't take too long to complete, for example.