3 ms·
Goto isn't nonlocal. You know you'll only every jump from them, and that you'll only ever jump to the specified label.
by josephcsible 6y ago
Goto isn't nonlocal. You know you'll only every jump from them, and that you'll only ever jump to the specified label.
- coldtea 6y agoThe specified label is what makes goto no-local. You need to check the whole codebase to find out where you'll land. By your definition only [1] "come from" would be non-local. [1] https://en.wikipedia.org/wiki/COMEFROM https://en.wikipedia.org/wiki/COMEFROM
- josephcsible 6y ago> the whole codebase You can't goto out of a function, and you know there's exactly one such label inside it. If goto isn't local, then neither are function calls, since the function could be defined anywhere in the codebase.
- coldtea 6y ago>You can't goto out of a function You can with a goto expression and a label address available - though the behavior is undefined in C, so bets are off. And you can with longjump/setjump more explicitly.
- josephcsible 6y agoAre you talking about this? https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html https://gcc.gnu.org/onlinedocs/gcc/Labels-as-Values.html It's a GNU extension, not part of standard C at all.
- gpderetta 6y agoFWIW, Normally the term "non local goto" is reserved for control transfer beyond the current activation frame. So C goto is strictly local, bit longjmp would be non-local.