longjmp() erases recursion level

gwyn at BRL-VLD.ARPA gwyn at BRL-VLD.ARPA
Sun Aug 26 20:31:46 AEST 1984

From:      Doug Gwyn (VLD/VMB) <gwyn at BRL-VLD.ARPA>

I don't see how using setjmp/longjmp to short-circuit recursion is
any "cleaner" than the following:

{	...

{	static int level = 0;
	if ( ++level <= 1 )

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).

More information about the Comp.lang.c mailing list