Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!athena.mit.edu!scs From: scs@athena.mit.edu (Steve Summit) Newsgroups: comp.lang.c Subject: Re: Passing Arguments In C Message-ID: <7130@bloom-beacon.MIT.EDU> Date: 20 Sep 88 05:19:34 GMT References: <2232@ssc-vax.UUCP> Sender: daemon@bloom-beacon.MIT.EDU Reply-To: scs@adam.pika.mit.edu (Steve Summit) Lines: 40 In article <2232@ssc-vax.UUCP> dmg@ssc-vax.UUCP (David Geary) writes: >I teach an Advanced C class, and am showing my students how to write variadic >functions. I want to make sure that what I'm telling them is correct, and >also want to prepared to answer the questions in the above paragraph. As several people have pointed out, with incongruous reservations, the right ways to write a variadic function are with varargs and stdarg. I'd like to: 1. remove the reservations -- these are the only right ways to do it 2. encourage you not to get your students too involved in what's going on "under the covers," even after your largely correct suppositions have been corrected by several previous articles. There is a widespread conception that C can only be understood in the context of the machine code being generated underneath. Understanding that code is indeed fascinating, but exploring it and writing programs which make use of it usually leads to unwarranted further confusion. Too often impressionable new students of the C language "learn" the unintended lesson that all C programs are arcane masterpieces of obfuscation which depend for their operation and understanding on specific details of the underlying hardware. There are "Intro to C programming" books, intended for beginners, which are filled with program upon machine-dependent program for finding out how the particular implementation works. If you're interested in writing clean, portable code, you don't need or want to know this stuff. But if all of the example programs you see while learning are obscure, those are the kinds of programs you will write. Steve Summit scs@adam.pika.mit.edu P.S. I'm sure that the heresy in this article will get flamed by all of the obfuscation fans out there, and I'd list and rebut all of the counterarguments I'm sure I'll get, but it's late and I want to keep this article short, so I guess I'll have to deal with them as they come.