ID:135317
![]() Oct 9 2004, 2:01 pm
|
|
Is there a method to check your entire code for infinite loops? Before saying "just use world.loop_checks", I don't want to protect from loops. I mean like a find function like "Find Text" but in this cause, find an infinite loop.
|
Crispy wrote:
Urgh. world.loop_checks is evil. It offers no protection at all; just a completely false sense of security. Never, ever, EVER use world.loop_checks. The error message that tells you to do so doesn't know what it's talking about. Always keep world.loop_checks set to 0 (which is the default, so there's no reason for you to even MENTION world.loop_checks anywhere in your program). Um. The default is 1. =P http://www.byond.com/docs/ref/info.html#/world/var/ loop_checks |
Actually, I have had some cases where I had to change that variable. I have had some steep recursive calls before that were not actually infinite but were thought to be by Byond and required me to change it. That is the exception, not the rule; but it does happen (like being struck by lightning or winning the lotto jackpot).
|
Uh ... yeah, you're right. Oops. Take what I said and turn it around. Reverse it! Actually, I'll edit it myself. =P
|
Like many rules, you have to learn it and fully appreciate the reasons behind it before you're allowed to break it. =)
In general, though, if you're doing something in a game that requires you to set world.loop_checks to 0, the solution is not to set world.loop_checks to 0; it's to stop doing it. =P The infinite loop check is far too useful to disable unless you REALLY know what you're doing. And I mean REALLY know. |
No, there isn't an automatic way to test for infinite loops. That would be very hard to write into Dream Maker; the only way to reliably test for infinite loops is to run the program and see what happens. And Dream Seeker already does that to some extent (though it doesn't if the loop sleeps, or loops by endlessly spawn()ing a proc).
The only reliable way is to do it manually; read through your code, spotting places where infinite loops could occur, and fixing them.