Path: utzoo!attcan!uunet!husc6!bloom-beacon!oberon!cit-vax!elroy!ames!pacbell!att!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704a-Liber) Newsgroups: comp.lang.c Subject: Re: Variable argument lists. Message-ID: <4824@ihlpf.ATT.COM> Date: 20 May 88 23:27:42 GMT References: <14139@brl-adm.ARPA> <504@sas.UUCP> <1777@rpp386.UUCP> <5485@aw.sei.cmu.edu> <5451@bloom-beacon.MIT.EDU> Reply-To: nevin1@ihlpf.UUCP (00704a-Liber,N.J.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 43 In article <5451@bloom-beacon.MIT.EDU> raeburn@athena.mit.edu (Ken Raeburn) writes: >How about the average number of arguments passed to variadic >functions? They're the only ones that should need the information. >Yes, I realize that includes *printf, some of the most-used functions. >(And *scanf too, but who in their right mind uses those anyways? :->) >And the work that they do quite likely far outways the cost of an >extra argument, especially since that argument is going to be a >constant known at compile-time. Yes, but things like *printf() have to *interpret* the first argument to find out all the necessary info on the rest of the variables (such as type). Also, someone might pass to *printf() n+1 parameters and change the format string so that only n-k parameters get printed. >I wouldn't mind a very slight extra cost for runtime code to catch >that missing argument to printf when I goof up. Unless this is caught at *compile* time, I have no need or want of this check. What normally happens when you give it too few arguments? It either prints funny results or it bombs with a memory error. What happens if the check is put in? Very likely, the program would just die (same thing happens in Pascal with range errors; this is one of the primary reasons that I dislike Pascal). The programs I write need to be able to recover from errors. I want good, efficient code that does not pay a penalty because some of the people who code in C don't do it correctly. If I can get all my printf/scanf's correct, why should I pay a penalty?? >And for those who do insist on using *scanf, it's probably of greater >importance. While printf might by chance pick up some stack garbage >or random stuff in data space, or could die by reaching outside the >address space, scanf will probably cause trouble by overwriting the >same information. Are there any statistics on this kind of stuff? As you have stated, *printf is used a lot. For this reason alone, I want it to be as fast as possible. -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_