[net.lang.c] Why not a varargs declaration?

rf@wu1.UUCP (11/01/83)

Maybe C should provide a standard way to pass a variable number
of arguments to a function.  One could provide a varags
declaration:

   varargs f() . . .

I'm aware that it would be difficult to provide a quick way to
do this on all machines, but the capability seems useful enough
so that the loss of execution time might be justifiable.  It
would, for instance, decrease the effort required to port an i/o
library.

A possible alternative might be to provide an Ada-like aggregate
notation.  Then one might write:

   fprintf (outfile, "%s %d\n", (@string, &i@));

The (@ . . . @) notation would assemble its arguments in
ascending order in main memory.  This might provide a fairly
clean way to pass variable numbers of parameters.
   
   
   				Randolph Fritz
				Western Union Telegraph

ka@hou3c.UUCP (Kenneth Almquist) (11/14/83)

System V has a set of macros for handling functions with a variable number
of arguments in a machine independent manner.  (The macros themselves are
different on the IBM and other machines which have oddities in their calling
sequences.)  Hopefully Berkeley will pick these up at some point.
					Kenneth Almquist

thomas@utah-gr.UUCP (Spencer W. Thomas) (11/14/83)

We've had varargs.h in our usr/include since at least 4.1bsd.

=Spencer

notes@pur-ee.UUCP (11/15/83)

#R:hou3c:-10800:ecn-ee:13100008:000:309
ecn-ee!davy    Nov 14 07:32:00 1983


Berkeley HAS picked up the macros for variable arguments.  See varargs(3).
They've been around ever since 4.0 BSD, at least.  Strange, though, out of
all the variable argument routines I've seen in the Berkeley code, and
other stuff, I've never once seen anyone USE these macros!

--Dave Curry
pur-ee!davy

ka@hou3c.UUCP (Kenneth Almquist) (11/15/83)

A correction to my previous posting.  Mark Horton has pointed out that
varargs.h also exists in V7 and Berkeley UNIX (although it isn't documented
in V7).
					Kenneth Almquist

andree@uokvax.UUCP (11/20/83)

#R:wu1:-18500:uokvax:3000007:000:496
uokvax!andree    Nov  9 06:05:00 1983

Might I also suggest coping the void function argument ala:

	f(varargs) <what DO you put here?>; {

Or, better yet:

	f(a, b, varargs) int a, b; <ditto>; {

Varargs f() isn't bad - I think the above fits C better (how do
you declare a pointer to struct gort as varargs?). Agregates
strike me as a BAD idea.  Though reasonable in and of
themselves, they would seem to require a major mod to C.

I vaguely recall (possibly wrongly) a rumor that some at Bell
was working on such a creature.

	<mike