Quote:
|
Originally Posted by elford
Plus...I don't see how you can use them to get around loops. In a current project I'm doing, there's a data structure called a linked list, and i need a loop to do something on every node of the list, there is no way of not doing that without a loop.
|
You just have a conditionally executed goto to a label where the loop should start. This is how loops are done in assembly. The example of a linked list is good -- you'll actually have less code trying to find a specific node with a loop than using a goto structure.
while (not last node) {
if (this node = the node i want)
break;
this node = next node;
} start:
if (this is the last node)
goto end;
if (this node = the node i want)
goto end;
this node = next node;
goto start;
end:
The first is a lot cleaner, especially if you have a situation in which you need nested looping constructs.