karl@haddock.UUCP (09/01/87)
In article <2211@emory.uucp> arnold@emory.UUCP (Arnold D. Robbins {EUCC}) writes: >[Suggests a new symbol "`" to represent arrays manipulated by value] If ANSI can be convinced not to repeat a certain K&R mistake, most of the cases you describe could be written without the new punctuator. To pass an array by value and/or return one: char foo(char arg[INSIZE])[OUTSIZE]; Once the prototype is in scope, "a1 = foo(a2)" can be interpreted properly. The array copy operation, "a1 = a2", is best handled by amending the array-to- -pointer conversion rule so that it does not attempt to convert "a2" in this context. (Note that this depends on "a1" being an array, not a pointer.) As has already been pointed out, most array manipulation in C at present is done via pointers instead. For fixed-length arrays this is not a problem; after "p = (int *)malloc(100 * sizeof(int));" one could copy the entire array by naming it "*(int (*)[100])p". (Better yet, one could make p a pointer to array in the first place: "p = (int (*)[100])malloc(sizeof(int[100]));" ... "*p".) Variable-sized arrays are trickier. I don't think it's appropriate to make "array of char" a magic synonym for "NUL-terminated string"; that partially solves one special case rather than the general problem. It smacks of PASCAL kludgery. The general problem of variable-sized arrays probably does require a new punctuator. I have an idea on this, too, but it needs more refinement. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint