Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.1 6/24/83; site wu1.UUCP Path: utzoo!linus!philabs!seismo!harpo!floyd!cmcl2!rocky2!cubsvax!wu1!rf From: rf@wu1.UUCP Newsgroups: net.lang.c Subject: A suggested addition to C. Message-ID: <214@wu1.UUCP> Date: Wed, 21-Dec-83 13:46:14 EST Article-I.D.: wu1.214 Posted: Wed Dec 21 13:46:14 1983 Date-Received: Fri, 23-Dec-83 04:39:24 EST Organization: Western Union Telegraph, Mahwah, NJ Lines: 60 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