[net.lang.c] A suggested addition to C.

rf@wu1.UUCP (12/21/83)

I'd like to propose the addition of a thing I've called an
"array constructor" to C.  I devised array constructors to
provide a graceful, portable way to write routines with variable
numbers of parameters.

*Example.

Here is an example of a routine call
which uses an array constructor:

   newscanf ("%s %d\n", (@ str, &errc @));

The newscanf routine might begin:

   typedef union {
      int *mt_ip;
      long int *mt_lp;
      float *mt_fp;
      double *mt_dp;
      char *mt_cp;
      char **mt_cpp;
      } manytp;

   newscanf (s, args)
      char *s;
      manytp *args;


The "next element" of the constructed array might be found by
"args++;"

*Syntax summary:

   primary:
          identifier
	  constant
	  string
	  . . .
	  (@ expression-list @)

*Semantics:

The expressions in expression-list are evaluated at run-time and
placed at ascending memory locations from left to right.  The
order of evaluation is not determined by the defintion though
the order in which the expressions are stored in memory is.
Each expression is given the amount of storage appropriate to
its size.

The storage required for the constructed array could come from
one of two places: the run-time stack or static storage.  Of the
two, the run-time stack is prefererable (since it saves storage)
but, given the structure of C compilers, this may be difficult
to arrange.  Static storage is perfectly workable--the overhead
is no worse than that of strings.

Comments?  Suggestions?

				Randolph Fritz
				Western Union Telegraph