Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site watmath.UUCP Path: utzoo!watmath!kpmartin From: kpmartin@watmath.UUCP (Kevin Martin) Newsgroups: net.lang.c Subject: Re: Varargs in C - (nf) Message-ID: <8806@watmath.UUCP> Date: Wed, 29-Aug-84 14:02:40 EDT Article-I.D.: watmath.8806 Posted: Wed Aug 29 14:02:40 1984 Date-Received: Thu, 30-Aug-84 00:26:26 EDT References: <13800005@smu.UUCP> Reply-To: kpmartin@watmath.UUCP (Kevin Martin) Organization: U of Waterloo, Ontario Lines: 31 >This is fundamentally the same as the varargs used in 4.2 but is >slightly different in that a pointer to the current stack frame >can be passed to another function. I think the 4.2 varargs does let you pass such a pointer to another function. You declare the callee as accepting a parameter of type 'va_list', and it should be able to use this variable just like the variables of type 'va_list' in the original (varargs) function. >Note that there are two items which I have not included in this >specification. One is a simple method of getting the number of >arguements passed. The other item is a method of determining >the types of the arguements passed. I feel that both of these >are bad since they force the information to be passed around all >of the time >Perry >convex!smu!pedz Many stack implementations already support an argument count of some sort. Sometimes it is an actual word or byte count. Other times, it is the count of passed values (i.e. a large struct passed by value only counts as one). The way to use this portably is to have some way of testing the pointer-to-next-arg for being beyond the last argument, sort of like an eof function. As for type information for each argument, it is not clear that this is useful in most cases... The callee would either ignore it, or blow up if it is wrong (at great expense of decoding the type info...). Basically, there is a vast difference between the ratios of (cost of implementation + cost of use) :: advantage of feature for having an arg count and for having arg type info. Kevin Martin, UofW Software Development Group