= First-class Arrays = == Motivation and basic concepts == C uses an "array-pointer" pun. This is not a particularly useful feature and leads to a lot of confusion. In C, code such as {{{ void f(double[] x) {…} double a[10]; … f(a); … }}} is automatically converted to {{{ void f(double *x) {…} double a[10]; … f(&a[0]); … }}} Moreover, in C there is no way to pass an array value as an argument to a function, or return an array value, or assign an array value to a variable of array type, all features we would like to include in CIVL-C. CIVL-C maintains backwards compatibility with C. To enable the new features above, a new type of declaration of variables of array type is introduced, using double brackets instead of single brackets. Both forms declare the same type (array of T), but variables declared with double brackets will not have the automatic conversions to pointers applied to them. The double-bracket objects can also be passed as parameters in function calls (without conversion), assigned, and returned by functions. For example: {{{ int[[]] double(int a[[]], int n) { int b[[n]]; for (int i=0; i