4 ms·
Agreed, infinite loops are a little hard to protect using asserts. When I hit the first infinite loop bug on a code path, I frequently add code to assert that
by luser001 14y ago
Agreed, infinite loops are a little hard to protect using asserts.
When I hit the first infinite loop bug on a code path, I frequently add code to assert that the number of calls is less than $A_LARGE_NUMBER to catch future occurrences of the same root cause.
- badgar 14y ago> Agreed, infinite loops are a little hard to protect using asserts. assert(is_tree(comment_graph)) Typically, a composite entity (like an "item" on HN which has many "comments") will define invariants to ensure data integrity. In this case, the invariant is that an "item"'s comments form a tree. The database layer often contains this logic, but it depends on how you're building your application; NoSQL backends for example typically must put validation in the application layer. Since HN just uses files, a well-developed application layer should be riddled with invariants like this.
- mpweiher 14y agoI dimly remember a language that just hard-limited loops. I thought it was John Pane's HANDS system, but I can't seem to find a reference in the thesis...can anybody refresh my memory? http://www.cs.cmu.edu/~pane/research.html http://www.cs.cmu.edu/~pane/research.html http://www.cs.cmu.edu/~pane/thesis/ http://www.cs.cmu.edu/~pane/thesis/ Pretty cool work regardless, I really like the way it deals with aggregates, for example.
- swah 14y agoThis is similar to the "while with timeout" that is common in embedded code (of course, watchdogs are better...)