Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site watmath.UUCP Path: utzoo!watmath!kpmartin From: kpmartin@watmath.UUCP (Kevin Martin) Newsgroups: net.lang.c Subject: More fun with types... Message-ID: <10980@watmath.UUCP> Date: Thu, 17-Jan-85 23:05:46 EST Article-I.D.: watmath.10980 Posted: Thu Jan 17 23:05:46 1985 Date-Received: Fri, 18-Jan-85 03:02:01 EST Distribution: net Organization: U of Waterloo, Ontario Lines: 45 All the following assumes the existance of the formal parameter declarations as described in the proposed draft standard. The basic observation is that the formal parameter information is actually part of the function's type, rather than a separate characteristic of the function itself. That is, if I say extern int fun( char *, int ); 'fun' is not a function returning int, and a function accepting arguments of type char * and int, but is actually a function of type "function accepting a char * and an int returning int". Similarly, I can type things like typedef int (*funny)( char *, int ); which is a pointer to function accepting a char * and an int returning an int. An object of type 'funny' could be used to point to 'fun'. Question: Given the above, and: extern int herbie( int, double ); should I be allowed to assign a pointer to 'herbie' to an object of type 'funny'? In other words, should pointer-to-function types be considered assignment-compatible ONLY if both the return type and the formal parameter declarations match? Related questions: What about functions for which no formal parameter declaration has been supplied? How about making such types assignment-compatible as long as the return type is the same, and all the arguments match in a somewhat looser sense, i.e. int matches unsigned, char * matches unsigned char *, as well as other such type pairs which are "usually assumed" to be identical? The current situation is that function pointer types are assignment- compatible as long as the return types are the same. If the strict interpretation is taken, the number of distinct pointers to functions will become quite large even for a small set of return types, and it is back to the old question: What do we use for a generic function pointer? Kevin Martin, UofW Software Development Group