Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site wateng.UUCP Path: utzoo!watmath!wateng!ksbszabo From: ksbszabo@wateng.UUCP (Kevin Szabo) Newsgroups: net.lang.c Subject: Re: When does void make code less readable? Message-ID: <2034@wateng.UUCP> Date: Mon, 18-Feb-85 14:59:59 EST Article-I.D.: wateng.2034 Posted: Mon Feb 18 14:59:59 1985 Date-Received: Tue, 19-Feb-85 06:08:29 EST References: <1995@sun.uucp> Reply-To: ksbszabo@wateng.UUCP (Kevin Szabo) Distribution: net Organization: VLSI Group, U of Waterloo Lines: 40 Summary: In article <1995@sun.uucp> tut@sun.uucp (Bill Tuthill) writes: +-------- |In general, void is A Good Thing. C routines that return a value |are like Pascal functions, while C routines not returning values |are like Pascal procedures, and should be declared as void to keep |things clear. +-------- I thought that just using `return' instead of `return ( expression )' told lint that the function wasn't returning a value, and hence the returned value could be ignored. VOID tells lint that a value is returned but it is ignored. Please correct me if I am wrong! +-------- |However, some system/library routines, such as close(), |fclose(), and free() return values that programs don't usually care |about. If the system is unable to close a file, you've got problems |that a normal program can't deal with anyway. +-------- I agree. I think it would be a useful thing for routines that normally "can't" fail, or return values that are ignored 90% of the time, to provide instead a general `event' handling function. This could probably look a little like the signal handling stuff. Thus we can have event( FAILED_PRINTF, bad_exit ); event( FAILED_MALLOC, garbage_collect ); By default `events' could probably be a PERROR with an exit(1). This scheme is not perfect but is much better than having to VOID every system call that should always work. It is also a lot better than segmentation faults/bus errors that occur when you try to carry on after an unchecked system call does fail. Of course, it adds complexity which is why it wasn't done this way in the first place. After perusing the manual pages on our machine it looks like the Math Faculty Computing Facility (at U of Waterloo) has already made a stab at providing these event handling facilities for their new stuff. I don't know anything about them though. Kevin -- Kevin Szabo watmath!wateng!ksbszabo (U of Waterloo VLSI Group, Waterloo Ont.)