4 ms·
GCC also has dynamic gotos as a C extension, called „computed gotos”. See: https://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables
by nathell 5y ago
GCC also has dynamic gotos as a C extension, called „computed gotos”. See:
https://eli.thegreenplace.net/2012/07/12/computed-goto-for-efficient-dispatch-tables https://eli.thegreenplace.net/2012/07/12/computed-goto-for-e...
https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html
- fiddlerwoaroof 5y agoFirst class functions are also very similar to dynamic gotos: https://dspace.mit.edu/handle/1721.1/5753 https://dspace.mit.edu/handle/1721.1/5753
- throwaway81523 5y agoThat is not much used directly by human C programmers. It's more for using C as a target language for another compiler, or in some cases as a fast dispatch in an interpreter. GNU Forth (gforth) uses it to dispatch between Forth words, for example.
- josephcsible 5y agoIt's kind of unfair to compare this to ALTER. Most of the time you're not using `goto *something;`, and when you're not, you know exactly where it's going to go. With COBOL's ALTER, it's as if every single goto were a computed goto, with the value of all of them being stored in global variables.