Path: utzoo!attcan!uunet!husc6!necntc!ima!haddock!karl From: karl@haddock.ISC.COM (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: Variable argument lists. Message-ID: <3962@haddock.ISC.COM> Date: 12 May 88 19:54:06 GMT References: <14139@brl-adm.ARPA> <11435@mimsy.UUCP> <5266@bloom-beacon.MIT.EDU> <11453@mimsy.UUCP> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 19 In article <11453@mimsy.UUCP> chris@mimsy.UUCP (Chris Torek) writes: >[C is not typeless; its values are really pairs; ignoring the > part is dangerous.] And this is the problem with va_count(): even if >it uses a `hidden argument' (something other than the [VMS] return byte >count), it can only tell you how many arguments there were. It cannot tell >you their types. In short, it is not general enough for C. It couldn't handle polymorphic functions like printf(), but it would still be useful for monomorphic functions like execl() or multistrcat(). (Using a sentinel at the end of the list is error-prone, and if the type in question is not a pointer, there may not be any appropriate out-of-band value to use. Using an explicit argcount variable is also error-prone ("Computers are much better than humans at counting"), and nontrivial in the face of #if'd args.) Actually, va_count() may be more powerful than we need. We could eliminate the problem of what the "count" really means; all we really need is a boolean that will tell us when we're at the end of the arglist. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint