cdiggins.com

June 20, 2007

Simple Infinite Loop Detection in Cat

Filed under: Everything — cdiggins @ 5:26 am

It is a law of computability that there is no way to guarantee that all infinite loops in a program can be identified, however detecting any infinite loop is always a good thing. Some infinite loops in Cat can be identified using a very simple algorithm: if a reference to the function occurs outside of any quotation, then we know there is an infinite loop. For example:

define f { a b f c d } // definitely at least one infinite loop

define f { a b [f] c d } // can’t say whether or not there is an infinite loop

This simple observation is due to the fact that we know control flow passes through every word outside of a quotation. Isn’t static analysis of Cat fun? I love Cat and Joy because they are chock full of these really nifty properties.

No Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress