Simple Infinite Loop Detection in Cat
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.