News for hackers. Stuff that matters.
Re:The Elegance of Deflate by chubot on Monday August 22, 2016 @05:10AM (#12334995)
I see setjmp/longjmp used a lot in recursive descent parsers in C.

I think people got tired of using up their return values for error codes. And it is more efficient to use this style certainly than manually breaking out of each stack frame.

C is full of things like this which break abstractions -- it doesn't seem particularly odd to me. Though I do remember that it was one of the things at the end of C books that I didn't understand for a long time.

What's the downside?

It doesn't play well with C++ because destructors have to be run at the end of every scope, but that doesn't apply to C.

And I guess because it mutates globals, it is a bit confusing in a threaded context.

Re:The Elegance of Deflate by gpderetta on Monday August 22, 2016 @10:02AM (#12336367)
> And I guess because it mutates globals, it is a bit confusing in a threaded context.

What globals?

Re:The Elegance of Deflate by chubot on Monday August 22, 2016 @02:23PM (#12338288)
My understanding is it works a bit like errno. errno is global that is set by the callee and then the caller can check it whenever, not necessarily right after the call or in the same function. But it's actually a thread-local, so it works fine in a threaded context, but is just a little odd to look at.