YALF (yet another lint foulup)

David Goodenough dg at lakart.UUCP
Wed Jan 4 02:39:39 AEST 1989


>From article <9255 at smoke.BRL.MIL>, by gwyn at smoke.BRL.MIL (Doug Gwyn ):
> In article <14672 at cisunx.UUCP> cmf at unix.cis.pittsburgh.edu (Carl M. Fongheiser) writes:
>>In article <9228 at smoke.BRL.MIL> gwyn at brl.arpa (Doug Gwyn (VLD/VMB) <gwyn>) writes:
>>>Function value type and whether a function returns are orthogonal.
>>Really?  I'm having a good deal of difficulty thinking of any reason why
>>one would declare a function which never returns as anything other than
>>void.
> 
> Where did you get the word "never"?

Probably from the same place I did for the example below

> 	unsigned int Square(unsigned int n)
> 	{	extern void exit(int);
> 		extern void /*also nonreturning*/ Fatal(char*);
> 		if (n >= 0x80)
> 			Fatal("overflow in Square");
> 		return n*n;
> 	}
> 
> This, not entirely implausible, function sometimes returns and
> sometimes doesn't.  But that has nothing to do with its type.

True, but probably irrelevant. What Mr. Fongheiser is referring to is something
like:

void command()
 {
    extern void exit();

    for (;;)
     {
	switch (getchar())
	 {
	    case 'q':
	      exit();
	    /* NOTREACHED */
	    case 'a':
	      a_command();
	    break;

		/* etc. etc. */
	 }
     }
    /* NOTREACHED */
 }

command() can NEVER (repeat NEVER) return. Hence to give it (say) type int
is not sensible, meaningful or anything.

:-) :-) smiley mode on :-) :-)
What is in fact needed is ANOTHER function type notreturning, as opposed
to void, because in one way void implies return, it also however imples
return without a corresponding return value. notreturning imples that
a function is a one way thing. lint could be made a lot more sensible
about exit() if such a thing existed, and if we could figure out how to
tell it about for (;;) without breaks, we could do away with
/* NOTREACHED */
-- 
	dg at lakart.UUCP - David Goodenough		+---+
							| +-+-+
	....... !harvard!xait!lakart!dg			+-+-+ |
AKA:	dg%lakart.uucp at xait.xerox.com		  	  +---+



More information about the Comp.lang.c mailing list