if (e1) return e2; [else] s1;

Ronald BODKIN utility at quiche.cs.mcgill.ca
Tue Mar 27 08:29:52 AEST 1990


In article <10624 at alice.UUCP> ark at alice.UUCP (Andrew Koenig) writes:
>Some people take the view that except at the end of a function,
>`return' is just a funny way of spelling `goto.'
Is this reallly a clearer and neater way of coding:
int foo()
{
	int ret;
	if (cond1) {
		/* do stuff */
		ret=1;
	}
	else {
		/* do other stuff */
		ret=2;
	}
	return ret;
}

This is slower and more cumbersome, IMHO.  After all, while and until
and for are also funny ways of spelling goto...
	Ron



More information about the Comp.lang.c mailing list