7 ms·
These are used /everywhere/ in PostgreSQL, exactly for exception handling. The result isn't bad at all, but indeed, too powerful a tool for 99% of developers
by slovenlyrobot 7y ago
These are used /everywhere/ in PostgreSQL, exactly for exception handling. The result isn't bad at all, but indeed, too powerful a tool for 99% of developers
- fanf2 7y agoAnd Lua’s exceptions are somewhat odd because they are based on setjmp/longjmp. https://www.lua.org/manual/5.3/manual.html#4.6 https://www.lua.org/manual/5.3/manual.html#4.6
- crankylinuxuser 7y agoAnd that's the perfect usage for goto. Error catching and jump to fail block...
- johannes1234321 7y agoGoto requires the fail block to be in the same frame. It can be a working error strategy for failing critical errors in such a way from a failing module. You have to be aware that lots of stuff is prone to leak (which can be avoided by i.e. using some memory arena) and locks/mutexes/... might be in unclear state, so code has to be aware of that.
- userbinator 7y agoThe destination of the goto is usually the clean-up code.
- johannes1234321 7y agoThat's nice for the single frame. Let's take the example of PostgreSQL, which was mentioned in this thread: A potential implementation (I have no knowledge of pgsql internals) might be that for a single user session all memory is from a single arena, all locks and other handles are tied to the session handle, then it can be an efficient strategy to longjmp out on a critical error (i.e. IO error) and clean the arena as well as things tied to the session. instead of bubbling this up through all frames.
- Mikhail_Edoshin 7y agoIt's a different use case. There was a nice article[1] about exceptions in plain C with setjmp and longjmp. [1] http://www.on-time.com/ddj0011.htm http://www.on-time.com/ddj0011.htm
- IshKebab 7y agoYou're in the 1% though right? Funny way of saying "too error-prone for anyone sane to consider using".
- deleted 7y ago[deleted]
- CamperBob2 7y agoFortunately, 99% of developers, like 99% of drivers, are better than average.
- cmroanirgo 7y ago> 99% ... are better than average. I'm thinking there's a flaw in your mathematics...
- mrbungie 7y agoNo flaw with math/stats here, that can actually happen. I think you're confusing average/mean with median (50-percentile). PS: I'm not sure where he's getting his numbers though
- elgenie 7y ago99% of the people on Earth have a higher than average number of legs.
- saalweachter 7y agoAnd a below-average number of heads.
- Stratoscope 7y agoYou've never been on a project that was 80% done and 80% to go?
- masklinn 7y agoApparently they're also used for error handling in libpng. That's one of the reasons the libspng author started on their project.