The most probable cause for infinite looping is, in my opinion, bad design. DikuMUDs in particular suffer from this because of their linked-list design. They use the idiom of "a data element in the list is a node in the list". Consider:
[code] a -> b -> c -> a[/quote]
We can see that iterating this is an infinite loop, because the node a points to the node b. Now consider using the "list node and data element are distinct" option:
[code]
node -> node -> node -> node
a b c a
[/quote]
(Eh? the code tag is not monospaced?)
Even though a is incorrectly in the list twice, there is no infinite loop when iterating over the list because the last node is still the last node.
This approach has its drawbacks, though: it takes more memory and probably more (although negligible) processor time when iterating. It also requires more memory management, because each node must be dynamically created.
|