On Friday, 27 July 2012 at 03:26:22 UTC, Nick Sabalausky wrote:
I didn't think that was true in C? It's certainly true in D, anyway.

It is, C and D have more or less the same goto rules.

goto.c:
===
void a() {
        goto cool;
}

void main() {
        a();
        cool: ;
}
===
$ gcc goto.c
goto.c: In function a:
goto.c:2: error: label cool used but not defined



While you can still kinda sorta spaghetti in C, the fact
that it is limited to a function makes it much easier to
follow. There's only one function to look at, not the
whole program.

The requirement of a label is important too, since any
particular line of code can't be a comes-from point;
unless there is a label there, you can be pretty confident
that the line before is actually run before.



Reply via email to