News for hackers. Stuff that matters.
Re:Banned C standard library functions in Git source code by zzo38computer on Sunday August 25, 2019 @12:37PM (#20793885)
I don't use setjmp() and longjmp() often, but sometimes I do; I use goto more often than those (but still not all the time). (I want goto in JavaScript too. I figured out a algorithm to do so, but have not implemented it.)

One use of setjmp/longjmp I have used is in ZORKMID, to deal with the debugger. At the beginning of the execute() function I have:

  while(setjmp(exception_buffer));
(The semicolon is correct; the loop body is supposed to be empty.) Normally, if you enter the debugger and then you exit the debugger to continue the execution, then it will continue from where it left off, which is likely in the middle of the execution of some instruction, and may result the same error again. But, if you change the program counter before continuing execution, then the debugger will keep track of that and will use longjmp instead when continuing execution, therefore skipping the rest of the instruction that stopped.
Re:Banned C standard library functions in Git source code by pault on Sunday August 25, 2019 @03:30PM (#20794976)
What can you accomplish with goto that you can't accomplish with try/catch and custom errors?
Re:Banned C standard library functions in Git source code by hibbelig on Monday August 26, 2019 @09:05AM (#20799534)
> What can you accomplish with goto that you can't accomplish with try/catch and custom errors?

You can program in C. C doesn't have try/catch...

Re:Banned C standard library functions in Git source code by dtech on Sunday August 25, 2019 @03:57PM (#20795124)
Goto sounds like a generally bad idea in a more expressive language like Javascript. Can you give an example of some Javascript-with-goto code that would be better than vanilla Javascript?
Re:Banned C standard library functions in Git source code by zzo38computer on Sunday August 25, 2019 @04:41PM (#20795429)
I have sometimes encountered such thing (but I do not remember right now), but what I do know is that goto is more helpful in C than in JavaScript. That doesn't mean that goto isn't worth anything in JavaScript, but only that there are less circumstances where it is useful compared to the other stuff. (The same is true of macros.)