From: utzoo!decvax!cca!gwyn@Brl@sri-unix Newsgroups: net.unix-wizards Title: Why C is not much better than Pascal at times Article-I.D.: sri-unix.3318 Posted: Fri Sep 17 01:35:19 1982 Received: Fri Sep 17 06:32:02 1982 From: Doug GwynDate: 14 Sep 82 0:07:02-EDT (Tue) One of BWK's complaints about Pascal was that the size of an array is part of its type, so one cannot write reasonable library routines to deal with variable-length arrays (such as char strings). Much as I like C, it suffers from a similar problem: double norm( n, matrix ) /* returns norm of n x n matrix */ int n; double matrix[n][n]; /* ILLEGAL! */ { ... (Note that the first subscript might as well be 1, due to row major order.) Since there is no ambiguity about what is meant here, and in fact no way to pass an actual array of data as an actual parameter, one would expect the compiler to generate reasonable code within the function body. What actually happens, on all C compilers I have tried so far, is that the compiler claims that ONLY CONSTANT subscripts can be used in the formal array declaration! I suppose that the compiler is written so that sizes have to be constants even in cases where variables make sense. I urge that consideration be given to removing this restriction at least for formal array parameters, since routines like this are obviously useful and currently difficult to code cleanly.