Newsgroups: comp.lang.c Path: utzoo!henry From: henry@utzoo.uucp (Henry Spencer) Subject: Re: Variable argument lists. Message-ID: <1988May12.165430.17228@utzoo.uucp> Organization: U of Toronto Zoology References: <14139@brl-adm.ARPA> Date: Thu, 12 May 88 16:54:30 GMT > Does anybody know (or care) why in ANSI standard C when > using a variable length argument list, there is no way to > determine how many arguments where passed into the function? Because it's costly and usually unnecessary. On the VAX it happens to be free, since the VAX's all-singing-all-dancing-slow-like-turtle function call instructions give it to you. Well, they give you a *word* count, not an argument count, and the difference matters if you start using various data types, but sloppy programmers ignore that. On most other machines, though, the only way to get a count is if the caller carefully provided you with one. This can add significantly to the cost of a well-tuned function-call convention -- and that's not a trivial issue, because C programs do *lots* of function calls. > Without such a feature it seems to me that the most of the > power of the variable argument list is wasted... Nonsense. Printf and friends don't need it, because the format string implicitly contains this information. Execl and friends don't need it, because their arg list is null-terminated. Yes, there are situations where it would be useful, but not all that many of them. -- NASA is to spaceflight as | Henry Spencer @ U of Toronto Zoology the Post Office is to mail. | {ihnp4,decvax,uunet!mnetor}!utzoo!henry