Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!decvax!ittvax!dcdwest!sdcsvax!sdcrdcf!hplabs!sri-unix!gwyn@BRL-VLD.ARPA From: gwyn@BRL-VLD.ARPA Newsgroups: net.lang.c Subject: Re: longjmp() erases recursion level Message-ID: <12837@sri-arpa.UUCP> Date: Sun, 26-Aug-84 06:31:46 EDT Article-I.D.: sri-arpa.12837 Posted: Sun Aug 26 06:31:46 1984 Date-Received: Thu, 30-Aug-84 19:40:06 EDT Lines: 23 From: Doug Gwyn (VLD/VMB) I don't see how using setjmp/longjmp to short-circuit recursion is any "cleaner" than the following: main() { ... sub(); ... } sub() { static int level = 0; ... if ( ++level <= 1 ) sub(); --level; } This method also lets you select a more general "recursion depth", useful for example in searching game trees, and sub() can return a value to its parent if required (as it usually would be in a practical application).